Ensure _.defaultsDeep doesn't convert function properties to objects. [closes #1783]

This commit is contained in:
John-David Dalton
2016-01-13 21:20:05 -08:00
parent f92dc95c58
commit fe3d86bf13
2 changed files with 13 additions and 1 deletions

View File

@@ -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;
}
/**

View File

@@ -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);