Skip to content

Commit 3ee6b62

Browse files
committed
Restore some stuff from sveltejs#15469, but differently
1 parent 587c385 commit 3ee6b62

File tree

1 file changed

+20
-0
lines changed
  • packages/svelte/src/internal/client/reactivity

1 file changed

+20
-0
lines changed

packages/svelte/src/internal/client/reactivity/props.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,13 @@ export function props(...props) {
266266
);
267267
}
268268

269+
/**
270+
* @param {Derived} derived
271+
*/
272+
function is_paused_or_destroyed(derived) {
273+
return (derived.f & (DESTROYED | INERT)) !== 0;
274+
}
275+
269276
/**
270277
* This function is responsible for synchronizing a possibly bound prop with the inner component state.
271278
* 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) {
399406
return (inner_current_value.v = parent_value);
400407
});
401408

409+
// Ensure we eagerly capture the initial value if it's bindable
410+
if (bindable) {
411+
get(current_value);
412+
}
413+
402414
if (!immutable) current_value.equals = safe_equals;
403415

404416
return function (/** @type {any} */ value, /** @type {boolean} */ mutation) {
@@ -426,12 +438,20 @@ export function prop(props, key, flags, fallback) {
426438
fallback_value = new_value;
427439
}
428440

441+
if (is_paused_or_destroyed(current_value)) {
442+
return value;
443+
}
444+
429445
untrack(() => get(current_value)); // force a synchronisation immediately
430446
}
431447

432448
return value;
433449
}
434450

451+
if (is_paused_or_destroyed(current_value)) {
452+
return value;
453+
}
454+
435455
return get(current_value);
436456
};
437457
}

0 commit comments

Comments
 (0)