From 329492377c2b000b26dc7dee2e4ff7c978ae8129 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:28:36 -0700 Subject: [PATCH] fix: don't access requestAnimationFrame eagerly --- packages/svelte/src/internal/client/timing.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/svelte/src/internal/client/timing.js b/packages/svelte/src/internal/client/timing.js index dc7d2ce4edf0..18dfc6c58397 100644 --- a/packages/svelte/src/internal/client/timing.js +++ b/packages/svelte/src/internal/client/timing.js @@ -3,13 +3,11 @@ import { noop } from '../shared/utils.js'; import { BROWSER } from 'esm-env'; -const request_animation_frame = BROWSER ? requestAnimationFrame : noop; - const now = BROWSER ? () => performance.now() : () => Date.now(); /** @type {Raf} */ export const raf = { - tick: /** @param {any} _ */ (_) => request_animation_frame(_), + tick: /** @param {any} _ */ (_) => (BROWSER ? requestAnimationFrame : noop)(_), now: () => now(), tasks: new Set() };