pull/16150/head
Rich Harris 3 months ago
parent fa97c56aca
commit 27fe22bf5c

@ -603,11 +603,11 @@ function resume_children(effect, local) {
// effects can schedule themselves for execution // effects can schedule themselves for execution
if ((effect.f & CLEAN) === 0) { if ((effect.f & CLEAN) === 0) {
effect.f ^= CLEAN; effect.f ^= CLEAN;
} } else {
// If a dependency of this effect changed while it was paused,
// If a dependency of this effect changed while it was paused, // schedule the effect to update. we don't use `check_dirtiness`
// schedule the effect to update // here because we don't want to eagerly recompute a derived like
if (check_dirtiness(effect, true)) { // `{#if foo}{foo.bar()}{/if}` if `foo` is now `undefined
set_signal_status(effect, DIRTY); set_signal_status(effect, DIRTY);
schedule_effect(effect); schedule_effect(effect);
} }

@ -151,10 +151,9 @@ export function increment_write_version() {
* Determines whether a derived or effect is dirty. * Determines whether a derived or effect is dirty.
* If it is MAYBE_DIRTY, will set the status to CLEAN * If it is MAYBE_DIRTY, will set the status to CLEAN
* @param {Reaction} reaction * @param {Reaction} reaction
* @param {boolean} [resuming]
* @returns {boolean} * @returns {boolean}
*/ */
export function check_dirtiness(reaction, resuming = false) { export function check_dirtiness(reaction) {
var flags = reaction.f; var flags = reaction.f;
if ((flags & DIRTY) !== 0) { if ((flags & DIRTY) !== 0) {
@ -203,18 +202,7 @@ export function check_dirtiness(reaction, resuming = false) {
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
dependency = dependencies[i]; dependency = dependencies[i];
if (check_dirtiness(/** @type {Derived} */ (dependency), resuming)) { if (check_dirtiness(/** @type {Derived} */ (dependency))) {
/* Don't execute deriveds when unpausing, for example when outer resumes
{#if outer}
{#if inner}
{inner.func()}
{/if}
{/if}
inner might be undefined, so don't eagerly execute `inner.func()`
*/
if (resuming) return true;
update_derived(/** @type {Derived} */ (dependency)); update_derived(/** @type {Derived} */ (dependency));
} }

Loading…
Cancel
Save