Skip to content

Commit

Permalink
fix: respect the unidirectional nature of time (#14541)
Browse files Browse the repository at this point in the history
* fix: respect the unidirectional nature of time

* note to our future selves
  • Loading branch information
Rich-Harris authored Dec 4, 2024
1 parent d511104 commit 4e77bde
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/sixty-tables-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: respect the unidirectional nature of time
7 changes: 5 additions & 2 deletions packages/svelte/src/internal/client/loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4e77bde

Please sign in to comment.