Performance hacks

This commit is contained in:
Pieter Vander Vennet 2022-01-06 18:51:52 +01:00
parent 686fb29ed3
commit 7090a5ceb8
15 changed files with 167 additions and 93 deletions

View file

@ -7,7 +7,7 @@ export class Translation extends BaseUIElement {
public static forcedLanguage = undefined;
public readonly translations: object
constructor(translations: object, context?: string) {
super()
if (translations === undefined) {
@ -33,6 +33,11 @@ export class Translation extends BaseUIElement {
get txt(): string {
return this.textFor(Translation.forcedLanguage ?? Locale.language.data)
}
Destroy() {
super.Destroy();
this.isDestroyed = true;
}
static ExtractAllTranslationsFrom(object: any, context = ""): { context: string, tr: Translation }[] {
const allTranslations: { context: string, tr: Translation }[] = []
@ -90,7 +95,11 @@ export class Translation extends BaseUIElement {
InnerConstructElement(): HTMLElement {
const el = document.createElement("span")
const self = this
Locale.language.addCallbackAndRun(_ => {
if(self.isDestroyed){
return true
}
el.innerHTML = this.txt
})
return el;