Skip to content

Commit

Permalink
fix: don't access requestAnimationFrame eagerly (#14026)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann authored Oct 30, 2024
1 parent b3437e6 commit 08bc37a
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions packages/svelte/src/internal/client/timing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
};

0 comments on commit 08bc37a

Please sign in to comment.