From: Michael Brevard Date: Fri, 11 Oct 2024 03:22:01 +0000 (+0300) Subject: fix(hydration): provide compat fallback for idle callback hydration strategy (#11935) X-Git-Tag: v3.5.12~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ae545a3786abef983be1c969726489685569c92;p=thirdparty%2Fvuejs%2Fcore.git fix(hydration): provide compat fallback for idle callback hydration strategy (#11935) --- diff --git a/packages/runtime-core/src/hydrationStrategies.ts b/packages/runtime-core/src/hydrationStrategies.ts index bb98ea93c2..bad3988483 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.