stash/ui/v2.5/src/polyfills.ts
WithoutPants a9ac176e91
Mobile UI improvements (#1104)
* Use dropdown for o-counter instead of hover
* Always show previews on non-hoverable device
* Add IntersectionObserver polyfill
* Prevent video previews playing fullscreen
2021-02-26 16:13:34 +11:00

31 lines
1.3 KiB
TypeScript

import replaceAll from "string.prototype.replaceall";
import { shouldPolyfill as shouldPolyfillCanonicalLocales } from "@formatjs/intl-getcanonicallocales/should-polyfill";
import { shouldPolyfill as shouldPolyfillLocale } from "@formatjs/intl-locale/should-polyfill";
import { shouldPolyfill as shouldPolyfillNumberformat } from "@formatjs/intl-numberformat/should-polyfill";
import { shouldPolyfill as shouldPolyfillPluralRules } from "@formatjs/intl-pluralrules/should-polyfill";
import "intersection-observer/intersection-observer";
// Required for browsers older than August 2020ish. Can be removed at some point.
replaceAll.shim();
async function checkPolyfills() {
if (shouldPolyfillCanonicalLocales()) {
await import("@formatjs/intl-getcanonicallocales/polyfill");
}
if (shouldPolyfillLocale()) {
await import("@formatjs/intl-locale/polyfill");
}
if (shouldPolyfillNumberformat()) {
await import("@formatjs/intl-numberformat/polyfill");
await import("@formatjs/intl-numberformat/locale-data/en");
await import("@formatjs/intl-numberformat/locale-data/en-GB");
}
if (shouldPolyfillPluralRules()) {
await import("@formatjs/intl-pluralrules/polyfill");
await import("@formatjs/intl-pluralrules/locale-data/en");
}
}
export const initPolyfills = async () => {
await checkPolyfills();
};