WIP (reduce number of with_parent calls, move towards possibility of combining tag and tag_proxy)

pull/16126/head
Rich Harris 3 months ago
parent d2487f81b5
commit b1f761c197

@ -97,23 +97,20 @@ export function proxy(value) {
e.state_descriptors_fixed(); e.state_descriptors_fixed();
} }
with_parent(() => {
var s = sources.get(prop); var s = sources.get(prop);
if (s === undefined) { if (s === undefined) {
s = with_parent(() => source(descriptor.value, stack)); s = source(descriptor.value, stack);
sources.set(prop, s); sources.set(prop, s);
if (DEV && typeof prop === 'string') { if (DEV && typeof prop === 'string') {
tag(s, get_label(path, prop)); tag(s, get_label(path, prop));
} }
} else { } else {
var p = with_parent(() => proxy(descriptor.value)); set(s, descriptor.value, true);
set(s, p);
if (DEV) {
tag_proxy(p, get_label(path, prop));
}
} }
});
return true; return true;
}, },
@ -278,22 +275,24 @@ export function proxy(value) {
// object property before writing to that property. // object property before writing to that property.
if (s === undefined) { if (s === undefined) {
if (!has || get_descriptor(target, prop)?.writable) { if (!has || get_descriptor(target, prop)?.writable) {
s = with_parent(() => source(undefined, stack)); s = with_parent(() => {
var p = with_parent(() => proxy(value)); var s = source(undefined, stack);
set(s, proxy(value));
return s;
});
if (DEV) { if (DEV) {
var label = get_label(path, prop); var label = get_label(path, prop);
tag(s, label); tag(s, label);
tag_proxy(p, label); tag_proxy(s.v, label);
} }
set(s, p);
sources.set(prop, s); sources.set(prop, s);
} }
} else { } else {
has = s.v !== UNINITIALIZED; has = s.v !== UNINITIALIZED;
p = with_parent(() => proxy(value)); var p = with_parent(() => proxy(value));
if (DEV) { if (DEV) {
tag_proxy(p, get_label(path, prop)); tag_proxy(p, get_label(path, prop));

Loading…
Cancel
Save