mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
Ensure _.defaultsDeep doesn't convert function properties to objects. [closes #1783]
This commit is contained in:
@@ -5099,7 +5099,9 @@
|
||||
stack.set(srcValue, objValue);
|
||||
baseMerge(objValue, srcValue, mergeDefaults, stack);
|
||||
}
|
||||
return objValue === undefined ? baseClone(srcValue) : objValue;
|
||||
return objValue === undefined
|
||||
? baseClone(srcValue, undefined, undefined, key, object)
|
||||
: objValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
10
test/test.js
10
test/test.js
@@ -3998,6 +3998,16 @@
|
||||
assert.strictEqual(actual.a.b, null);
|
||||
});
|
||||
|
||||
QUnit.test('should not convert function properties to objects', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var actual = _.defaultsDeep({}, { 'a': noop });
|
||||
assert.strictEqual(actual.a, noop);
|
||||
|
||||
actual = _.defaultsDeep({}, { 'a': { 'b': noop } });
|
||||
assert.strictEqual(actual.a.b, noop);
|
||||
});
|
||||
|
||||
QUnit.test('should overwrite `undefined` values', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user