diff --git a/.changeset/sixty-tables-fold.md b/.changeset/sixty-tables-fold.md new file mode 100644 index 000000000000..83182344cece --- /dev/null +++ b/.changeset/sixty-tables-fold.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: respect the unidirectional nature of time diff --git a/packages/svelte/src/internal/client/loop.js b/packages/svelte/src/internal/client/loop.js index d1c73e344fa3..9c1e972800fd 100644 --- a/packages/svelte/src/internal/client/loop.js +++ b/packages/svelte/src/internal/client/loop.js @@ -4,10 +4,13 @@ import { raf } from './timing.js'; // TODO move this into timing.js where it probably belongs /** - * @param {number} now * @returns {void} */ -function run_tasks(now) { +function run_tasks() { + // use `raf.now()` instead of the `requestAnimationFrame` callback argument, because + // otherwise things can get wonky https://github.com/sveltejs/svelte/pull/14541 + const now = raf.now(); + raf.tasks.forEach((task) => { if (!task.c(now)) { raf.tasks.delete(task);