mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +00:00
Fix failing Backbone test and ensure _.assign works properly with a customizer that returns undefined.
This commit is contained in:
@@ -1694,11 +1694,12 @@
|
|||||||
if (customizer) {
|
if (customizer) {
|
||||||
var value = object[key],
|
var value = object[key],
|
||||||
result = customizer(value, source[key], key, object, source);
|
result = customizer(value, source[key], key, object, source);
|
||||||
|
|
||||||
|
if (result !== value || (typeof value == 'undefined' && !(key in object))) {
|
||||||
|
object[key] = result;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
result = source[key];
|
object[key] = source[key];
|
||||||
}
|
|
||||||
if (!(customizer && result === value)) {
|
|
||||||
object[key] = result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return object;
|
return object;
|
||||||
|
|||||||
@@ -953,6 +953,11 @@
|
|||||||
deepEqual(actual, { 'a': 1, 'b': 2, 'c': 3 });
|
deepEqual(actual, { 'a': 1, 'b': 2, 'c': 3 });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should work with a `customizer` that returns `undefined`', 1, function() {
|
||||||
|
var expected = { 'a': undefined };
|
||||||
|
deepEqual(_.assign({}, expected, _.identity), expected);
|
||||||
|
});
|
||||||
|
|
||||||
test('should be aliased', 1, function() {
|
test('should be aliased', 1, function() {
|
||||||
strictEqual(_.extend, _.assign);
|
strictEqual(_.extend, _.assign);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user