Ensure _.where handles properties with undefined properties. [closes #461]

This commit is contained in:
John-David Dalton
2014-01-27 08:16:10 -08:00
parent 752545ec0e
commit 6cef7d5060
8 changed files with 69 additions and 38 deletions

View File

@@ -557,7 +557,7 @@
* @memberOf _
* @category Utilities
* @param {Object} [context=root] The context object.
* @returns {Function} Returns the `lodash` function.
* @returns {Function} Returns a new `lodash` function.
*/
function runInContext(context) {
// Avoid issues with some ES3 environments that attempt to use values, named
@@ -6933,6 +6933,9 @@
// property containing a primitive value
if (props.length == 1 && a === a && !isObject(a)) {
return function(object) {
if (!hasOwnProperty.call(object, key)) {
return false;
}
var b = object[key];
return a === b && (a !== 0 || (1 / a == 1 / b));
};
@@ -6942,7 +6945,9 @@
result = false;
while (length--) {
if (!(result = baseIsEqual(object[props[length]], source[props[length]], null, true))) {
var key = props[length];
if (!(result = hasOwnProperty.call(object, key) &&
baseIsEqual(object[key], source[key], null, true))) {
break;
}
}