[Glitch] Provides legacy fallback for browser that don't support regex flag v

Port 28b0e5ee78 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Echo
2025-08-04 19:15:46 +02:00
committed by Claire
parent a6f0ec160e
commit b8f66e1d33
4 changed files with 54 additions and 21 deletions

View File

@@ -20,5 +20,16 @@ export function loadPolyfills() {
loadIntlPolyfills(),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- those properties might not exist in old browsers, even if they are always here in types
needsExtraPolyfills && importExtraPolyfills(),
loadEmojiPolyfills(),
]);
}
// In the case of no /v support, rely on the emojibase data.
async function loadEmojiPolyfills() {
if (!('unicodeSets' in RegExp.prototype)) {
emojiRegexPolyfill = (await import('emojibase-regex/emoji')).default;
}
}
// Null unless polyfill is needed.
export let emojiRegexPolyfill: RegExp | null = null;