Update lodash underscore build _.findWhere to follow v1.4.4 null behavior.

Former-commit-id: 7b6ce7e9d7cf032171f43835bbf907cf3ffeb908
This commit is contained in:
John-David Dalton
2013-02-01 01:55:42 -08:00
parent c1eff5aebb
commit d7fea5dc78
6 changed files with 81 additions and 47 deletions

View File

@@ -1782,6 +1782,10 @@
return result;
}
function findWhere(object, properties) {
return where(object, properties, true);
}
/**
* Iterates over a `collection`, executing the `callback` for each element in
* the `collection`. The `callback` is bound to `thisArg` and invoked with three
@@ -2351,7 +2355,9 @@
* // => [{ 'name': 'moe', 'age': 40 }]
*/
function where(collection, properties, first) {
return (first ? find : filter)(collection, properties);
return (first && isEmpty(properties))
? null
: (first ? find : filter)(collection, properties);
}
/*--------------------------------------------------------------------------*/
@@ -3957,7 +3963,7 @@
lodash.escape = escape;
lodash.every = every;
lodash.find = find;
lodash.findWhere = find;
lodash.findWhere = findWhere;
lodash.has = has;
lodash.identity = identity;
lodash.indexOf = indexOf;