Skip to content

Commit 89c2a32

Browse files
committed
refactor: improve flush condition clarity in revive() method
1 parent 04b686b commit 89c2a32

File tree

1 file changed

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

1 file changed

+9
-9
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ export class Batch {
304304

305305
dep.f ^= WAS_MARKED;
306306

307-
this.#clear_marked(/** @type {Derived} */ (dep).deps);
307+
this.#clear_marked(/** @type {Derived} */(dep).deps);
308308
}
309309
}
310310

@@ -503,8 +503,8 @@ export class Batch {
503503
this.#dirty_effects = [];
504504
this.#maybe_dirty_effects = [];
505505

506-
// Always flush if we have pending work that needs to be resolved
507-
if (this.#pending === 0 || queued_root_effects.length > 0) {
506+
// Flush if there are queued root effects, or if there is no pending work left.
507+
if (queued_root_effects.length > 0 || this.#pending === 0) {
508508
this.flush();
509509
}
510510

@@ -789,14 +789,14 @@ function mark_effects(value, sources, marked, checked) {
789789
const flags = reaction.f;
790790

791791
if ((flags & DERIVED) !== 0) {
792-
mark_effects(/** @type {Derived} */ (reaction), sources, marked, checked);
792+
mark_effects(/** @type {Derived} */(reaction), sources, marked, checked);
793793
} else if (
794794
(flags & (ASYNC | BLOCK_EFFECT)) !== 0 &&
795795
(flags & DIRTY) === 0 &&
796796
depends_on(reaction, sources, checked)
797797
) {
798798
set_signal_status(reaction, DIRTY);
799-
schedule_effect(/** @type {Effect} */ (reaction));
799+
schedule_effect(/** @type {Effect} */(reaction));
800800
}
801801
}
802802
}
@@ -816,10 +816,10 @@ function mark_eager_effects(value, effects) {
816816
const flags = reaction.f;
817817

818818
if ((flags & DERIVED) !== 0) {
819-
mark_eager_effects(/** @type {Derived} */ (reaction), effects);
819+
mark_eager_effects(/** @type {Derived} */(reaction), effects);
820820
} else if ((flags & EAGER_EFFECT) !== 0) {
821821
set_signal_status(reaction, DIRTY);
822-
effects.add(/** @type {Effect} */ (reaction));
822+
effects.add(/** @type {Effect} */(reaction));
823823
}
824824
}
825825
}
@@ -839,8 +839,8 @@ function depends_on(reaction, sources, checked) {
839839
return true;
840840
}
841841

842-
if ((dep.f & DERIVED) !== 0 && depends_on(/** @type {Derived} */ (dep), sources, checked)) {
843-
checked.set(/** @type {Derived} */ (dep), true);
842+
if ((dep.f & DERIVED) !== 0 && depends_on(/** @type {Derived} */(dep), sources, checked)) {
843+
checked.set(/** @type {Derived} */(dep), true);
844844
return true;
845845
}
846846
}

0 commit comments

Comments
 (0)