Skip to content

Commit 1ae545a

Browse files
fix(hydration): provide compat fallback for idle callback hydration strategy (#11935)
1 parent 05685a9 commit 1ae545a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/runtime-core/src/hydrationStrategies.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
import { isString } from '@vue/shared'
1+
import { getGlobalThis, isString } from '@vue/shared'
22
import { DOMNodeTypes, isComment } from './hydration'
33

4+
// Polyfills for Safari support
5+
// see https://caniuse.com/requestidlecallback
6+
const requestIdleCallback: Window['requestIdleCallback'] =
7+
getGlobalThis().requestIdleCallback || (cb => setTimeout(cb, 1))
8+
const cancelIdleCallback: Window['cancelIdleCallback'] =
9+
getGlobalThis().cancelIdleCallback || (id => clearTimeout(id))
10+
411
/**
512
* A lazy hydration strategy for async components.
613
* @param hydrate - call this to perform the actual hydration.

0 commit comments

Comments
 (0)