Use objValue instead of oldValue.

This commit is contained in:
John-David Dalton
2015-12-26 21:26:36 -06:00
parent 83ea7ac136
commit a5b9063088

View File

@@ -3036,28 +3036,28 @@
* @param {Object} [stack] Tracks traversed source values and their merged counterparts. * @param {Object} [stack] Tracks traversed source values and their merged counterparts.
*/ */
function baseMergeDeep(object, source, key, mergeFunc, customizer, stack) { function baseMergeDeep(object, source, key, mergeFunc, customizer, stack) {
var oldValue = object[key], var objValue = object[key],
srcValue = source[key], srcValue = source[key],
stacked = stack.get(oldValue) || stack.get(srcValue); stacked = stack.get(objValue) || stack.get(srcValue);
if (stacked) { if (stacked) {
assignMergeValue(object, key, stacked); assignMergeValue(object, key, stacked);
return; return;
} }
var newValue = customizer ? customizer(oldValue, srcValue, (key + ''), object, source, stack) : undefined, var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined,
isCommon = newValue === undefined; isCommon = newValue === undefined;
if (isCommon) { if (isCommon) {
newValue = srcValue; newValue = srcValue;
if (isArray(srcValue) || isTypedArray(srcValue)) { if (isArray(srcValue) || isTypedArray(srcValue)) {
newValue = isArray(oldValue) newValue = isArray(objValue)
? oldValue ? objValue
: ((isArrayLikeObject(oldValue)) ? copyArray(oldValue) : baseClone(srcValue)); : ((isArrayLikeObject(objValue)) ? copyArray(objValue) : baseClone(srcValue));
} }
else if (isPlainObject(srcValue) || isArguments(srcValue)) { else if (isPlainObject(srcValue) || isArguments(srcValue)) {
newValue = isArguments(oldValue) newValue = isArguments(objValue)
? toPlainObject(oldValue) ? toPlainObject(objValue)
: (isObject(oldValue) ? oldValue : baseClone(srcValue)); : (isObject(objValue) ? objValue : baseClone(srcValue));
} }
else { else {
isCommon = isFunction(srcValue); isCommon = isFunction(srcValue);
@@ -3314,10 +3314,10 @@
if (isObject(nested)) { if (isObject(nested)) {
var newValue = value; var newValue = value;
if (index != lastIndex) { if (index != lastIndex) {
var oldValue = nested[key]; var objValue = nested[key];
newValue = customizer ? customizer(oldValue, key, nested) : undefined; newValue = customizer ? customizer(objValue, key, nested) : undefined;
if (newValue === undefined) { if (newValue === undefined) {
newValue = oldValue == null ? (isIndex(path[index + 1]) ? [] : {}) : oldValue; newValue = objValue == null ? (isIndex(path[index + 1]) ? [] : {}) : objValue;
} }
} }
assignValue(nested, key, newValue); assignValue(nested, key, newValue);