Restore some stuff from #15469, but differently

pull/16140/head
Matei-Paul Trandafir 3 months ago
parent 587c385724
commit 3ee6b6204a
No known key found for this signature in database
GPG Key ID: BC96CA77836E14F8

@ -266,6 +266,13 @@ export function props(...props) {
);
}
/**
* @param {Derived} derived
*/
function is_paused_or_destroyed(derived) {
return (derived.f & (DESTROYED | INERT)) !== 0;
}
/**
* This function is responsible for synchronizing a possibly bound prop with the inner component state.
* It is used whenever the compiler sees that the component writes to the prop, or when it has a default prop_value.
@ -399,6 +406,11 @@ export function prop(props, key, flags, fallback) {
return (inner_current_value.v = parent_value);
});
// Ensure we eagerly capture the initial value if it's bindable
if (bindable) {
get(current_value);
}
if (!immutable) current_value.equals = safe_equals;
return function (/** @type {any} */ value, /** @type {boolean} */ mutation) {
@ -426,12 +438,20 @@ export function prop(props, key, flags, fallback) {
fallback_value = new_value;
}
if (is_paused_or_destroyed(current_value)) {
return value;
}
untrack(() => get(current_value)); // force a synchronisation immediately
}
return value;
}
if (is_paused_or_destroyed(current_value)) {
return value;
}
return get(current_value);
};
}

Loading…
Cancel
Save