mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Ensure _.mergeWith sources are cloned when customizer returns undefiend. [closes #2111]
This commit is contained in:
@@ -3219,7 +3219,7 @@
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
isCommon = false;
|
isCommon = false;
|
||||||
newValue = baseClone(srcValue, !customizer);
|
newValue = baseClone(srcValue, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
|
||||||
@@ -3228,7 +3228,7 @@
|
|||||||
}
|
}
|
||||||
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
|
||||||
isCommon = false;
|
isCommon = false;
|
||||||
newValue = baseClone(srcValue, !customizer);
|
newValue = baseClone(srcValue, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
newValue = objValue;
|
newValue = objValue;
|
||||||
|
|||||||
10
test/test.js
10
test/test.js
@@ -14610,6 +14610,16 @@
|
|||||||
assert.deepEqual(actual, { 'a': { 'b': ['c'] } });
|
assert.deepEqual(actual, { 'a': { 'b': ['c'] } });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('should clone sources when `customizer` result is `undefined`', function(assert) {
|
||||||
|
assert.expect(1);
|
||||||
|
|
||||||
|
var source1 = { 'a': { 'b': { 'c': 1 } } },
|
||||||
|
source2 = { 'a': { 'b': { 'd': 2 } } },
|
||||||
|
actual = _.mergeWith({}, source1, source2, alwaysUndefined);
|
||||||
|
|
||||||
|
assert.deepEqual(source1.a.b, { 'c': 1 });
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test('should pop the stack of sources for each sibling property', function(assert) {
|
QUnit.test('should pop the stack of sources for each sibling property', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user