Skip to content

Commit 8a35194

Browse files
authored
chore: tweak flushSync implementation (#15898)
1 parent eebb940 commit 8a35194

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/svelte/src/internal/client/runtime.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -828,15 +828,16 @@ export function flushSync(fn) {
828828
result = fn();
829829
}
830830

831-
flush_tasks();
831+
while (true) {
832+
flush_tasks();
833+
834+
if (queued_root_effects.length === 0) {
835+
return /** @type {T} */ (result);
836+
}
832837

833-
while (queued_root_effects.length > 0) {
834838
is_flushing = true;
835839
flush_queued_root_effects();
836-
flush_tasks();
837840
}
838-
839-
return /** @type {T} */ (result);
840841
}
841842

842843
/**

0 commit comments

Comments
 (0)