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