From 6a3d785505b0ed759e9806ce1845a86c1f11184e Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 15 Jul 2025 17:18:54 -0400 Subject: [PATCH] fix --- .../src/internal/client/reactivity/batch.js | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/svelte/src/internal/client/reactivity/batch.js b/packages/svelte/src/internal/client/reactivity/batch.js index 2189535adb..1f87c73856 100644 --- a/packages/svelte/src/internal/client/reactivity/batch.js +++ b/packages/svelte/src/internal/client/reactivity/batch.js @@ -299,6 +299,8 @@ export class Batch { deactivate() { current_batch = null; + + flush_pending_update(); } neuter() { @@ -322,13 +324,7 @@ export class Batch { batches.delete(this); } - current_batch = null; - - for (const update of effect_pending_updates) { - effect_pending_updates.delete(update); - update(); - break; - } + this.deactivate(); } flush_effects() { @@ -429,6 +425,18 @@ export class Batch { } } +function flush_pending_update() { + for (const update of effect_pending_updates) { + effect_pending_updates.delete(update); + update(); + + if (current_batch !== null) { + // only do one at a time + break; + } + } +} + /** * Synchronously flush any pending updates. * Returns void if no callback is provided, otherwise returns the result of calling the callback.