Skip to content

Commit 60b24de

Browse files
committed
only recurse into POJOs
1 parent d5791fb commit 60b24de

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

packages/svelte/src/internal/client/dev/ownership.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { STATE_SYMBOL } from '../constants.js';
44
import { render_effect } from '../reactivity/effects.js';
55
import { current_component_context, untrack } from '../runtime.js';
6+
import { get_prototype_of } from '../utils.js';
67

78
/** @type {Record<string, Array<{ start: Location, end: Location, component: Function }>>} */
89
const boundaries = {};
@@ -167,9 +168,18 @@ function add_owner_to_object(object, owner) {
167168
object[ADD_OWNER](owner);
168169
});
169170
} else {
170-
// recurse until we find a state proxy
171-
for (const key in object) {
172-
add_owner_to_object(object[key], owner);
171+
var proto = get_prototype_of(object);
172+
173+
if (proto === Object.prototype) {
174+
// recurse until we find a state proxy
175+
for (const key in object) {
176+
add_owner_to_object(object[key], owner);
177+
}
178+
} else if (proto === Array.prototype) {
179+
// recurse until we find a state proxy
180+
for (let i = 0; i < object.length; i += 1) {
181+
add_owner_to_object(object[i], owner);
182+
}
173183
}
174184
}
175185
}

packages/svelte/src/internal/client/runtime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ export function deep_read(value, visited = new Set()) {
11521152
// continue
11531153
}
11541154
}
1155-
const proto = Object.getPrototypeOf(value);
1155+
const proto = get_prototype_of(value);
11561156
if (
11571157
proto !== Object.prototype &&
11581158
proto !== Array.prototype &&

0 commit comments

Comments
 (0)