mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +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);
|
stack.set(srcValue, objValue);
|
||||||
baseMerge(objValue, srcValue, mergeDefaults, stack);
|
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);
|
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) {
|
QUnit.test('should overwrite `undefined` values', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user