Skip to content

Commit 3a7ec65

Browse files
committed
tweak
1 parent d4bd04f commit 3a7ec65

File tree

1 file changed

+17
-8
lines changed
  • packages/svelte/src/internal/client

1 file changed

+17
-8
lines changed

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ export function proxy(value, prev) {
5555
return s;
5656
};
5757

58-
/** @param {any} value */
59-
var child_proxy = (value) => {
58+
/** @param {() => void} fn */
59+
var with_parent = (fn) => {
6060
var previous_reaction = active_reaction;
6161
set_active_reaction(reaction);
6262
var previous_metadata = parent_metadata;
6363
parent_metadata = metadata;
64-
var p = proxy(value);
64+
var p = fn();
6565
set_active_reaction(previous_reaction);
6666
parent_metadata = previous_metadata;
6767
return p;
@@ -119,7 +119,10 @@ export function proxy(value, prev) {
119119
s = child_source(descriptor.value);
120120
sources.set(prop, s);
121121
} else {
122-
set(s, child_proxy(descriptor.value));
122+
set(
123+
s,
124+
with_parent(() => proxy(descriptor.value))
125+
);
123126
}
124127

125128
return true;
@@ -164,7 +167,7 @@ export function proxy(value, prev) {
164167

165168
// create a source, but only if it's an own property and not a prototype property
166169
if (s === undefined && (!exists || get_descriptor(target, prop)?.writable)) {
167-
s = child_source(child_proxy(exists ? target[prop] : UNINITIALIZED));
170+
s = child_source(with_parent(() => proxy(exists ? target[prop] : UNINITIALIZED)));
168171
sources.set(prop, s);
169172
}
170173

@@ -232,7 +235,7 @@ export function proxy(value, prev) {
232235
(active_effect !== null && (!has || get_descriptor(target, prop)?.writable))
233236
) {
234237
if (s === undefined) {
235-
s = child_source(has ? child_proxy(target[prop]) : UNINITIALIZED);
238+
s = child_source(has ? with_parent(() => proxy(target[prop])) : UNINITIALIZED);
236239
sources.set(prop, s);
237240
}
238241

@@ -272,12 +275,18 @@ export function proxy(value, prev) {
272275
if (s === undefined) {
273276
if (!has || get_descriptor(target, prop)?.writable) {
274277
s = child_source(undefined);
275-
set(s, child_proxy(value));
278+
set(
279+
s,
280+
with_parent(() => proxy(value))
281+
);
276282
sources.set(prop, s);
277283
}
278284
} else {
279285
has = s.v !== UNINITIALIZED;
280-
set(s, child_proxy(value));
286+
set(
287+
s,
288+
with_parent(() => proxy(value))
289+
);
281290
}
282291

283292
if (DEV) {

0 commit comments

Comments
 (0)