mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 00:57:48 +00:00
Make _.merge assign null values. [closes #151]
Former-commit-id: 5a839996db9475182d5957d2f8cb4b3c265b0d9f
This commit is contained in:
@@ -622,7 +622,7 @@
|
||||
(function() {
|
||||
var object = Object.freeze({
|
||||
'a': _.identity,
|
||||
'b': null
|
||||
'b': undefined
|
||||
});
|
||||
|
||||
['non-strict', 'strict'].forEach(function(strictMode, index) {
|
||||
@@ -736,7 +736,7 @@
|
||||
deepEqual(lodash.defaults({}, new Foo), Foo.prototype, '_.defaults should assign inherited `source` properties: ' + basename);
|
||||
deepEqual(lodash.extend({}, new Foo), Foo.prototype, '_.extend should assign inherited `source` properties: ' + basename);
|
||||
|
||||
actual = lodash.find(array, function(value) {
|
||||
var actual = lodash.find(array, function(value) {
|
||||
return 'a' in value;
|
||||
});
|
||||
|
||||
@@ -761,7 +761,7 @@
|
||||
|
||||
// avoid issues comparing objects with `deepEqual`
|
||||
object = { 'a': 1, 'b': 2, 'c': 3 };
|
||||
var actual = lodash.omit(object, function(value) { return value == 3; });
|
||||
actual = lodash.omit(object, function(value) { return value == 3; });
|
||||
deepEqual(_.keys(actual).sort(), ['a', 'b', 'c'], '_.omit should not accept a `callback`: ' + basename);
|
||||
|
||||
actual = lodash.pick(object, function(value) { return value != 3; });
|
||||
|
||||
10
test/test.js
10
test/test.js
@@ -1217,6 +1217,16 @@
|
||||
_.reduce(array, _.merge, actual);
|
||||
deepEqual(actual, { 'a': 1, 'b': 2, 'c': 3});
|
||||
});
|
||||
|
||||
test('should assign `null` values', function() {
|
||||
var actual = _.merge({ 'a': 1 }, { 'a': null });
|
||||
strictEqual(actual.a, null);
|
||||
});
|
||||
|
||||
test('should not assign `undefined` values', function() {
|
||||
var actual = _.merge({ 'a': 1 }, { 'a': undefined });
|
||||
equal(actual.a, 1);
|
||||
});
|
||||
}(1, 2, 3));
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user