fix(web): removes stylesheets from unloaded keyboards

This commit is contained in:
jahorton 2021-01-29 12:54:50 +07:00
parent a0b2fdb625
commit a67e26fb1c
2 changed files with 15 additions and 1 deletions

View file

@ -197,8 +197,10 @@ namespace com.keyman.osk {
s.fontSize = fontScale + 'em';
}
if(this.vkbd) {
this.vkbd.shutdown();
}
this.vkbd = null;
// TODO: Consider a 'vkbd.release()' method?
// Instantly resets the OSK container, erasing / delinking the previously-loaded keyboard.
this._Box.innerHTML = '';
@ -311,6 +313,9 @@ namespace com.keyman.osk {
* Description Generates the visual keyboard element and attaches it to KMW
*/
private _GenerateVisualKeyboard(keyboard: keyboards.Keyboard) {
if(this.vkbd) {
this.vkbd.shutdown();
}
this.vkbd = new com.keyman.osk.VisualKeyboard(keyboard);
let util = com.keyman.singleton.util;

View file

@ -2763,5 +2763,14 @@ namespace com.keyman.osk {
}, 5000);
return false;
};
shutdown() {
let keyman = com.keyman.singleton;
// Prevents style-sheet pollution from multiple keyboard swaps.
if(this.styleSheet) {
keyman.util.removeStyleSheet(this.styleSheet);
}
}
}
}