Skip to content

Commit 016f02b

Browse files
committed
tweak implementation
1 parent 9307ad5 commit 016f02b

File tree

1 file changed

+19
-16
lines changed
  • packages/svelte/src/internal/client

1 file changed

+19
-16
lines changed

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

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,9 @@ const regex_is_valid_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
2222
* @template T
2323
* @param {T} value
2424
* @param {string} [path]
25-
* @param {boolean} change_path
2625
* @returns {T}
2726
*/
28-
export function proxy(value, path, change_path = false) {
29-
if (DEV && change_path) {
30-
// @ts-expect-error
31-
value?.[PROXY_PATH_SYMBOL]?.(path);
32-
}
33-
27+
export function proxy(value, path) {
3428
// if non-proxyable, or is already a proxy, return `value`
3529
if (typeof value !== 'object' || value === null || STATE_SYMBOL in value) {
3630
return value;
@@ -261,19 +255,28 @@ export function proxy(value, path, change_path = false) {
261255
if (s === undefined) {
262256
if (!has || get_descriptor(target, prop)?.writable) {
263257
s = with_parent(() => source(undefined, stack));
264-
s = DEV ? tag(s, to_trace_name(prop)) : s;
265-
set(
266-
s,
267-
with_parent(() => proxy(value, to_trace_name(prop), true))
268-
);
258+
var p = with_parent(() => proxy(value, to_trace_name(prop)));
259+
260+
if (DEV) {
261+
var label = to_trace_name(prop);
262+
tag(s, label);
263+
p?.[PROXY_PATH_SYMBOL]?.(label);
264+
}
265+
266+
set(s, p);
269267
sources.set(prop, s);
270268
}
271269
} else {
272270
has = s.v !== UNINITIALIZED;
273-
set(
274-
s,
275-
with_parent(() => proxy(value, to_trace_name(prop), true))
276-
);
271+
272+
p = with_parent(() => proxy(value, to_trace_name(prop)));
273+
274+
if (DEV) {
275+
label = to_trace_name(prop);
276+
p?.[PROXY_PATH_SYMBOL]?.(label);
277+
}
278+
279+
set(s, p);
277280
}
278281

279282
var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);

0 commit comments

Comments
 (0)