From 1ae545a3786abef983be1c969726489685569c92 Mon Sep 17 00:00:00 2001 From: Michael Brevard Date: Fri, 11 Oct 2024 06:22:01 +0300 Subject: [PATCH] fix(hydration): provide compat fallback for idle callback hydration strategy (#11935) --- packages/runtime-core/src/hydrationStrategies.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/runtime-core/src/hydrationStrategies.ts b/packages/runtime-core/src/hydrationStrategies.ts index bb98ea93c20..bad39884830 100644 --- a/packages/runtime-core/src/hydrationStrategies.ts +++ b/packages/runtime-core/src/hydrationStrategies.ts @@ -1,6 +1,13 @@ -import { isString } from '@vue/shared' +import { getGlobalThis, isString } from '@vue/shared' import { DOMNodeTypes, isComment } from './hydration' +// Polyfills for Safari support +// see https://caniuse.com/requestidlecallback +const requestIdleCallback: Window['requestIdleCallback'] = + getGlobalThis().requestIdleCallback || (cb => setTimeout(cb, 1)) +const cancelIdleCallback: Window['cancelIdleCallback'] = + getGlobalThis().cancelIdleCallback || (id => clearTimeout(id)) + /** * A lazy hydration strategy for async components. * @param hydrate - call this to perform the actual hydration.