Fix string indexes with _.has in older enviros.

This commit is contained in:
jdalton
2015-04-07 21:23:32 -07:00
parent a83e70104c
commit 3c71f79929

View File

@@ -1063,8 +1063,7 @@
support.nodeTag = objToString.call(document) != objectTag; support.nodeTag = objToString.call(document) != objectTag;
/** /**
* Detect if string indexes are non-enumerable * Detect if string indexes are non-enumerable (IE < 9, RingoJS, Rhino, Narwhal).
* (IE < 9, RingoJS, Rhino, Narwhal).
* *
* @memberOf _.support * @memberOf _.support
* @type boolean * @type boolean
@@ -1072,8 +1071,7 @@
support.nonEnumStrings = !propertyIsEnumerable.call('x', 0); support.nonEnumStrings = !propertyIsEnumerable.call('x', 0);
/** /**
* Detect if properties shadowing those on `Object.prototype` are * Detect if properties shadowing those on `Object.prototype` are non-enumerable.
* non-enumerable.
* *
* In IE < 9 an object's own properties, shadowing non-enumerable ones, * In IE < 9 an object's own properties, shadowing non-enumerable ones,
* are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug). * are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug).
@@ -1095,11 +1093,11 @@
* Detect if `Array#shift` and `Array#splice` augment array-like objects * Detect if `Array#shift` and `Array#splice` augment array-like objects
* correctly. * correctly.
* *
* Firefox < 10, compatibility modes of IE 8, and IE < 9 have buggy Array `shift()` * Firefox < 10, compatibility modes of IE 8, and IE < 9 have buggy Array
* and `splice()` functions that fail to remove the last element, `value[0]`, * `shift()` and `splice()` functions that fail to remove the last element,
* of array-like objects even though the "length" property is set to `0`. * `value[0]`, of array-like objects even though the "length" property is
* The `shift()` method is buggy in compatibility modes of IE 8, while `splice()` * set to `0`. The `shift()` method is buggy in compatibility modes of IE 8,
* is buggy regardless of mode in IE < 9. * while `splice()` is buggy regardless of mode in IE < 9.
* *
* @memberOf _.support * @memberOf _.support
* @type boolean * @type boolean
@@ -4574,24 +4572,6 @@
return isObject(value) ? value : Object(value); return isObject(value) ? value : Object(value);
} }
/**
* Converts `value` to property path array if it is not one.
*
* @private
* @param {*} value The value to process.
* @returns {Array} Returns the property path array.
*/
function toPath(value) {
if (isArray(value)) {
return value;
}
var result = [];
baseToString(value).replace(rePropName, function(match, number, quote, string) {
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
});
return result;
}
/** /**
* Converts `value` to an object if it is not one. * Converts `value` to an object if it is not one.
* *
@@ -4613,6 +4593,24 @@
return isObject(value) ? value : Object(value); return isObject(value) ? value : Object(value);
} }
/**
* Converts `value` to property path array if it is not one.
*
* @private
* @param {*} value The value to process.
* @returns {Array} Returns the property path array.
*/
function toPath(value) {
if (isArray(value)) {
return value;
}
var result = [];
baseToString(value).replace(rePropName, function(match, number, quote, string) {
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
});
return result;
}
/** /**
* Creates a clone of `wrapper`. * Creates a clone of `wrapper`.
* *
@@ -9531,7 +9529,7 @@
object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
result = object != null && hasOwnProperty.call(object, last(path)); result = object != null && hasOwnProperty.call(object, last(path));
} }
return result; return result || (lodash.support.nonEnumStrings && isString(object) && isIndex(path, object.length));
} }
/** /**