Skip to content

Commit 0457804

Browse files
Fix signal update mutating unrelated properties
1 parent bd8d1e9 commit 0457804

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/adapter/shared/serialize.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,14 @@ export function maybeSetSignal(
211211
path: ObjPath,
212212
value: any,
213213
) {
214-
const last = path.slice().pop();
215-
const parent = path.reduce((acc, attr) => (acc ? acc[attr] : null), obj);
216-
if (parent && last) {
217-
if (isSignal(parent)) {
218-
parent.value = value;
214+
let current: any = obj;
215+
for (let i = 0; i < path.length; i++) {
216+
if (isSignal(current)) {
217+
current.value = value;
219218
return true;
220219
}
220+
221+
current = current[path[i]];
221222
}
222223

223224
return false;

0 commit comments

Comments
 (0)