Ensure _.merge doesn't modify array/typed-array/plain-object source values.

This commit is contained in:
John-David Dalton
2015-09-12 09:18:45 -07:00
parent 1320706172
commit dafe807888
2 changed files with 20 additions and 6 deletions

View File

@@ -2565,12 +2565,12 @@
if (isArray(srcValue) || isTypedArray(srcValue)) {
newValue = isArray(oldValue)
? oldValue
: ((isObject(oldValue) && isArrayLike(oldValue)) ? copyArray(oldValue) : srcValue);
: ((isObject(oldValue) && isArrayLike(oldValue)) ? copyArray(oldValue) : baseClone(srcValue));
}
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
newValue = isArguments(oldValue)
? toPlainObject(oldValue)
: (isObject(oldValue) ? oldValue : srcValue);
: (isObject(oldValue) ? oldValue : baseClone(srcValue));
}
else {
isCommon = isFunction(srcValue);