Skip to content

Commit 2dd70d6

Browse files
committed
3.0.0: Fix original nested objects being modified
1 parent 48e7175 commit 2dd70d6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

index.js

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ function mixin(target, val, key) {
2525
let obj = target[key];
2626
if (isObject(val) && isObject(obj)) {
2727
mixinDeep(obj, val);
28+
} else if (!(key in target) && isObject(val)) {
29+
// `target` can be mutated by later mixins. Therefore, if we are currently adding an object to `target`,
30+
// it could be mutated later. We need to make sure that mutation will not change the original data.
31+
target[key] = {...val};
2832
} else {
2933
target[key] = val;
3034
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mixin-deep",
33
"description": "Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone. No dependencies.",
4-
"version": "2.0.1",
4+
"version": "3.0.0",
55
"homepage": "https://github.com/jonschlinkert/mixin-deep",
66
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
77
"repository": "jonschlinkert/mixin-deep",

0 commit comments

Comments
 (0)