mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
Ensure _.defaultsDeep does not overwrite regexp values.
This commit is contained in:
@@ -5374,9 +5374,10 @@
|
||||
* @returns {*} Returns the value to assign.
|
||||
*/
|
||||
function mergeDefaults(objValue, srcValue, key, object, source, stack) {
|
||||
return (isObject(objValue) && isObject(srcValue))
|
||||
? baseMerge(objValue, srcValue, undefined, mergeDefaults, stack.set(srcValue, objValue))
|
||||
: objValue;
|
||||
if (isObject(objValue) && isObject(srcValue)) {
|
||||
baseMerge(objValue, srcValue, undefined, mergeDefaults, stack.set(srcValue, objValue));
|
||||
}
|
||||
return objValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
10
test/test.js
10
test/test.js
@@ -4350,6 +4350,16 @@
|
||||
assert.strictEqual(actual.a.b, null);
|
||||
});
|
||||
|
||||
QUnit.test('should not overwrite regexp values', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var object = { 'a': { 'b': /x/ } },
|
||||
source = { 'a': { 'b': /y/ } },
|
||||
actual = _.defaultsDeep(object, source);
|
||||
|
||||
assert.deepEqual(actual.a.b, /x/);
|
||||
});
|
||||
|
||||
QUnit.test('should not convert function properties to objects', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user