From 36a90594cee7d50de34613fb8b80ae3fa3cea0b0 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 2 Jul 2025 13:28:29 -0400 Subject: [PATCH] no idea what a 'boundary micro task' is or why it was deemed necessary but evidently it isn't --- .../svelte/src/internal/client/dom/task.js | 33 +++---------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/packages/svelte/src/internal/client/dom/task.js b/packages/svelte/src/internal/client/dom/task.js index 3d58d2215e..e3ec4642b2 100644 --- a/packages/svelte/src/internal/client/dom/task.js +++ b/packages/svelte/src/internal/client/dom/task.js @@ -6,22 +6,13 @@ const request_idle_callback = ? (/** @type {() => void} */ cb) => setTimeout(cb, 1) : requestIdleCallback; -/** @type {Array<() => void>} */ -let boundary_micro_tasks = []; - /** @type {Array<() => void>} */ let micro_tasks = []; /** @type {Array<() => void>} */ let idle_tasks = []; -function run_boundary_micro_tasks() { - var tasks = boundary_micro_tasks; - boundary_micro_tasks = []; - run_all(tasks); -} - -function run_post_micro_tasks() { +function run_micro_tasks() { var tasks = micro_tasks; micro_tasks = []; run_all(tasks); @@ -33,29 +24,13 @@ function run_idle_tasks() { run_all(tasks); } -function run_micro_tasks() { - run_boundary_micro_tasks(); - run_post_micro_tasks(); -} - -/** - * @param {() => void} fn - */ -export function queue_boundary_micro_task(fn) { - if (boundary_micro_tasks.length === 0 && micro_tasks.length === 0) { - queueMicrotask(run_micro_tasks); - } - - // TODO do we need to differentiate between `boundary_micro_tasks` and `micro_tasks`? - // nothing breaks if we push everything to `micro_tasks` - boundary_micro_tasks.push(fn); -} +export { queue_micro_task as queue_boundary_micro_task }; /** * @param {() => void} fn */ export function queue_micro_task(fn) { - if (boundary_micro_tasks.length === 0 && micro_tasks.length === 0) { + if (micro_tasks.length === 0) { queueMicrotask(run_micro_tasks); } @@ -77,7 +52,7 @@ export function queue_idle_task(fn) { * Synchronously run any queued tasks. */ export function flush_tasks() { - if (boundary_micro_tasks.length > 0 || micro_tasks.length > 0) { + if (micro_tasks.length > 0) { run_micro_tasks(); }