diff --git a/web/src/engine/dom-utils/src/stylesheets.ts b/web/src/engine/dom-utils/src/stylesheets.ts index e97dd63030..827320cad3 100644 --- a/web/src/engine/dom-utils/src/stylesheets.ts +++ b/web/src/engine/dom-utils/src/stylesheets.ts @@ -29,6 +29,10 @@ export class StylesheetManager { } linkStylesheet(sheet: HTMLStyleElement) { + if(!(sheet instanceof HTMLLinkElement) && !sheet.innerHTML) { + return; + } + this.linkedSheets.push(sheet); this.linkNode.appendChild(sheet); } @@ -51,6 +55,7 @@ export class StylesheetManager { } else { const promise = new ManagedPromise(); sheetElem.addEventListener('load', () => promise.resolve()); + sheetElem.addEventListener('error', () => promise.reject()); promises.push(promise.corePromise); } } @@ -174,12 +179,10 @@ export class StylesheetManager { * For now, we're using this solely to detect when the font has been succesfully loaded. */ const fontFace = new FontFace(fd.family, source); - const loadPromise = fontFace.load(); - this.fontPromises.push(loadPromise); const clearPromise = () => this.fontPromises = this.fontPromises.filter((entry) => entry != loadPromise); - loadPromise.then(clearPromise); - loadPromise.catch(clearPromise); + const loadPromise = fontFace.load().then(clearPromise).catch(clearPromise); + this.fontPromises.push(loadPromise); this.linkStylesheet(sheet); diff --git a/web/src/engine/osk/src/visualKeyboard.ts b/web/src/engine/osk/src/visualKeyboard.ts index 17a9d91ea9..e07ba634f8 100644 --- a/web/src/engine/osk/src/visualKeyboard.ts +++ b/web/src/engine/osk/src/visualKeyboard.ts @@ -1360,8 +1360,10 @@ export default class VisualKeyboard extends EventEmitter implements Ke if (activeKeyboard != null && typeof (activeKeyboard.oskStyling) == 'string') // KMEW-129 customStyle = customStyle + activeKeyboard.oskStyling; - this.styleSheet = createStyleSheet(customStyle); //Build 360 - this.styleSheetManager.linkStylesheet(this.styleSheet); + if(customStyle) { + this.styleSheet = createStyleSheet(customStyle); //Build 360 + this.styleSheetManager.linkStylesheet(this.styleSheet); + } // Once any related fonts are loaded, we can re-adjust key-cap scaling. this.styleSheetManager.allLoadedPromise().then(() => this.refreshLayout());