Skip to content

Commit 27fe22b

Browse files
committed
simplify
1 parent fa97c56 commit 27fe22b

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -603,11 +603,11 @@ function resume_children(effect, local) {
603603
// effects can schedule themselves for execution
604604
if ((effect.f & CLEAN) === 0) {
605605
effect.f ^= CLEAN;
606-
}
607-
608-
// If a dependency of this effect changed while it was paused,
609-
// schedule the effect to update
610-
if (check_dirtiness(effect, true)) {
606+
} else {
607+
// If a dependency of this effect changed while it was paused,
608+
// schedule the effect to update. we don't use `check_dirtiness`
609+
// here because we don't want to eagerly recompute a derived like
610+
// `{#if foo}{foo.bar()}{/if}` if `foo` is now `undefined
611611
set_signal_status(effect, DIRTY);
612612
schedule_effect(effect);
613613
}

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,9 @@ export function increment_write_version() {
151151
* Determines whether a derived or effect is dirty.
152152
* If it is MAYBE_DIRTY, will set the status to CLEAN
153153
* @param {Reaction} reaction
154-
* @param {boolean} [resuming]
155154
* @returns {boolean}
156155
*/
157-
export function check_dirtiness(reaction, resuming = false) {
156+
export function check_dirtiness(reaction) {
158157
var flags = reaction.f;
159158

160159
if ((flags & DIRTY) !== 0) {
@@ -203,18 +202,7 @@ export function check_dirtiness(reaction, resuming = false) {
203202
for (i = 0; i < length; i++) {
204203
dependency = dependencies[i];
205204

206-
if (check_dirtiness(/** @type {Derived} */ (dependency), resuming)) {
207-
/* Don't execute deriveds when unpausing, for example when outer resumes
208-
209-
{#if outer}
210-
{#if inner}
211-
{inner.func()}
212-
{/if}
213-
{/if}
214-
215-
inner might be undefined, so don't eagerly execute `inner.func()`
216-
*/
217-
if (resuming) return true;
205+
if (check_dirtiness(/** @type {Derived} */ (dependency))) {
218206
update_derived(/** @type {Derived} */ (dependency));
219207
}
220208

0 commit comments

Comments
 (0)