dont' fail if browser has no document.fonts
Massimo Melina committed
Jun 16, 2024 at 17:56 UTC
f209e71190bd9aa331261570ad8dc30dd1113e70
1 file changed
+3
-1
frontend/src/icons.ts
+3
-1
@@ -51,9 +51,11 @@ const documentComplete = document.readyState === 'complete' ? Promise.resolve()
51
: new Promise(res => document.addEventListener('readystatechange', res))
52
// fonts.ready seems to be unreliable with iphone + additional <script> in custom-html + plugins using frontend_js, but still can be interesting if it resolves faster the document.complete, as we specifically interested in the fonts
53
Promise.race([documentComplete, document.fonts?.ready]).then(async () => {
54
+ if (!document.fonts)
55
+ return state.iconsReady = true
56
const fontTester = '9px fontello'
57
await document.fonts.load(fontTester) // force font to be loaded even if we didn't display anything with it yet
56
- state.iconsReady = document.fonts.check(fontTester)//Boolean(Array.from(document.fonts.values()).find(x => x.family === 'fontello'))
58
+ state.iconsReady = document.fonts.check(fontTester)
59
})
60
61
interface IconProps { name:string, className?:string, alt?:string, [rest:string]: any }