diff --git a/packages/svelte/src/internal/client/reactivity/batch.js b/packages/svelte/src/internal/client/reactivity/batch.js index 5a041f9703..3c510f81d4 100644 --- a/packages/svelte/src/internal/client/reactivity/batch.js +++ b/packages/svelte/src/internal/client/reactivity/batch.js @@ -149,8 +149,6 @@ export class Batch { process(root_effects) { queued_root_effects = []; - previous_batch = null; - this.apply(); /** @type {Effect[]} */ @@ -168,14 +166,18 @@ export class Batch { // log_inconsistent_branches(root); } - if (!this.is_fork) { - this.#resolve(); - } - if (this.is_deferred()) { this.#defer_effects(render_effects); this.#defer_effects(effects); } else { + // append/remove branches + for (const fn of this.#commit_callbacks) fn(); + this.#commit_callbacks.clear(); + + if (this.#pending === 0) { + this.#commit(); + } + // If sources are written to, then work needs to happen in a separate batch, else prior sources would be mixed with // newly updated sources, which could lead to infinite loops when effects run over and over again. previous_batch = this; @@ -328,18 +330,6 @@ export class Batch { this.#discard_callbacks.clear(); } - #resolve() { - if (this.#blocking_pending === 0) { - // append/remove branches - for (const fn of this.#commit_callbacks) fn(); - this.#commit_callbacks.clear(); - } - - if (this.#pending === 0) { - this.#commit(); - } - } - #commit() { // If there are other pending batches, they now need to be 'rebased' — // in other words, we re-run block/async effects with the newly