add requestIdleCallback polyfill to fix Safari crash (#5689)
This commit is contained in:
parent
3df230393a
commit
117afdb67f
3 changed files with 27 additions and 0 deletions
|
|
@ -12,6 +12,8 @@ import { SWR_CONFIG } from "@/constants/swr-config";
|
||||||
import { resolveGeneralTheme } from "@/helpers/theme.helper";
|
import { resolveGeneralTheme } from "@/helpers/theme.helper";
|
||||||
// nprogress
|
// nprogress
|
||||||
import { AppProgressBar } from "@/lib/n-progress";
|
import { AppProgressBar } from "@/lib/n-progress";
|
||||||
|
// polyfills
|
||||||
|
import "@/lib/polyfills";
|
||||||
// mobx store provider
|
// mobx store provider
|
||||||
import { StoreProvider } from "@/lib/store-context";
|
import { StoreProvider } from "@/lib/store-context";
|
||||||
// wrappers
|
// wrappers
|
||||||
|
|
|
||||||
1
web/core/lib/polyfills/index.ts
Normal file
1
web/core/lib/polyfills/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
export * from "./requestIdleCallback";
|
||||||
24
web/core/lib/polyfills/requestIdleCallback.ts
Normal file
24
web/core/lib/polyfills/requestIdleCallback.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
if (typeof window !== "undefined" && window) {
|
||||||
|
// Add request callback polyfill to browser incase it does not exist
|
||||||
|
window.requestIdleCallback =
|
||||||
|
window.requestIdleCallback ??
|
||||||
|
function (cb) {
|
||||||
|
var start = Date.now();
|
||||||
|
return setTimeout(function () {
|
||||||
|
cb({
|
||||||
|
didTimeout: false,
|
||||||
|
timeRemaining: function () {
|
||||||
|
return Math.max(0, 50 - (Date.now() - start));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}, 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
window.cancelIdleCallback =
|
||||||
|
window.cancelIdleCallback ??
|
||||||
|
function (id) {
|
||||||
|
clearTimeout(id);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export {};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue