mirror of https://github.com/sveltejs/svelte
fix: ensure performance.now() and requestAnimationFrame() are polyfilled in ssr (#10715)
parent
a5a566dfa7
commit
622195cc21
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: ensure performance.now() and requestAnimationFrame() are polyfilled in ssr
|
@ -1,5 +1,13 @@
|
||||
import { noop } from '../common.js';
|
||||
|
||||
const is_client = typeof window !== 'undefined';
|
||||
|
||||
const request_animation_frame = is_client ? requestAnimationFrame : noop;
|
||||
|
||||
const now = is_client ? () => performance.now() : () => Date.now();
|
||||
|
||||
/** @type {import('./types.js').Raf} */
|
||||
export const raf = {
|
||||
tick: /** @param {any} _ */ (_) => requestAnimationFrame(_),
|
||||
now: () => performance.now()
|
||||
tick: /** @param {any} _ */ (_) => request_animation_frame(_),
|
||||
now: () => now()
|
||||
};
|
||||
|
Loading…
Reference in new issue