Skip to content

Commit 9de2ac5

Browse files
committed
Update proxy.js
1 parent 4b95df3 commit 9de2ac5

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/proxy.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ const nestedHandler = {
55
levels.push(key);
66
const topLevel = levels[0];
77
levels.shift();
8-
const copiedParent = Array.isArray(this._parent[topLevel])
9-
? [...this._parent[topLevel]]
10-
: { ...this._parent[topLevel] };
11-
const scope = deepcopy(copiedParent);
8+
const scope = deepcopy(this._parent[topLevel]);
129
let target = scope;
1310
const max_level = levels.length - 1;
1411
levels.some((level, i) => {
@@ -36,13 +33,12 @@ const nestedHandler = {
3633
(Object.prototype.toString.call(prop) === '[object Object]' &&
3734
prop?.constructor?.name === 'Object')
3835
) {
39-
const thisHandler = { ...nestedHandler };
36+
const thisHandler = deepcopy(nestedHandler);
4037
thisHandler._path = `${this._path}.${key}`;
4138
thisHandler._parent = this._parent;
4239
const isArray = Array.isArray(prop);
4340
thisHandler._array = isArray;
44-
const copied = isArray ? [...prop] : { ...prop };
45-
return new Proxy(copied, thisHandler);
41+
return new Proxy(deepcopy(prop), thisHandler);
4642
}
4743
return reflector;
4844
},
@@ -64,10 +60,10 @@ const proxyHandler = {
6460
Object.prototype.toString.call(getValue) === '[object Object]' &&
6561
getValue?.constructor?.name === 'Object'
6662
) {
67-
const thisHandler = { ...nestedHandler };
63+
const thisHandler = deepcopy(nestedHandler);
6864
thisHandler._path = key;
6965
thisHandler._parent = receiver;
70-
return new Proxy({ ...getValue }, thisHandler);
66+
return new Proxy(deepcopy(getValue), thisHandler);
7167
}
7268
return getValue;
7369
},

0 commit comments

Comments
 (0)