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

@@ -207,7 +207,7 @@ $(document).ready(function() {
strictEqual(_.result(obj, 'x'), 'x');
strictEqual(_.result(obj, 'y'), 'x');
strictEqual(_.result(obj, 'z'), undefined);
strictEqual(_.result(null, 'x'), undefined);
strictEqual(_.result(null, 'x'), null);
});
test('_.templateSettings.variable', function() {

View File

@@ -238,7 +238,7 @@
// Convenience version of a common use case of `filter`: selecting only objects
// containing specific `key:value` pairs.
_.where = function(obj, attrs, first) {
if (_.isEmpty(attrs)) return first ? void 0 : [];
if (_.isEmpty(attrs)) return first ? null : [];
return _[first ? 'find' : 'filter'](obj, function(value) {
for (var key in attrs) {
if (attrs[key] !== value[key]) return false;
@@ -1058,7 +1058,7 @@
// If the value of the named property is a function then invoke it;
// otherwise, return it.
_.result = function(object, property) {
if (object == null) return void 0;
if (object == null) return null;
var value = object[property];
return _.isFunction(value) ? value.call(object) : value;
};