diff --git a/packages/svelte/src/internal/client/runtime.js b/packages/svelte/src/internal/client/runtime.js index 90364e4454..738d8f28fb 100644 --- a/packages/svelte/src/internal/client/runtime.js +++ b/packages/svelte/src/internal/client/runtime.js @@ -763,7 +763,21 @@ function flush_queued_effects(effects) { * @returns {void} */ export function schedule_effect(signal) { - queue_flush(); + if (!is_flushing) { + is_flushing = true; + queueMicrotask(() => { + flush_queued_root_effects(); + + // TODO this doesn't seem quite right — may run into + // interesting cases where there are multiple roots. + // it'll do for now though + if (active_fork?.pending === 0) { + active_fork.remove(); + } + + remove_active_fork(); + }); + } var effect = (last_scheduled_effect = signal); @@ -788,24 +802,6 @@ export function schedule_effect(signal) { } } -function queue_flush() { - if (!is_flushing) { - is_flushing = true; - queueMicrotask(() => { - flush_queued_root_effects(); - - // TODO this doesn't seem quite right — may run into - // interesting cases where there are multiple roots. - // it'll do for now though - if (active_fork?.pending === 0) { - active_fork.remove(); - } - - remove_active_fork(); - }); - } -} - /** * * This function both runs render effects and collects user effects in topological order