From 15a4048730c60bd656fc806062d2ae2ac7754d3b Mon Sep 17 00:00:00 2001 From: jusax23 Date: Wed, 7 Dec 2022 20:27:57 +0100 Subject: [PATCH] fixes --- main.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/main.js b/main.js index 7e237a8..ee615ac 100644 --- a/main.js +++ b/main.js @@ -27,6 +27,8 @@ const pools = { }; +const stears = []; + /** Stear class */ export class Stear{ @@ -42,6 +44,13 @@ export class Stear{ constructor(elem){ this.elem = elem; elem.style.position="relative"; + stears.push(this); + } + destroy(){ + let i = stears.indexOf(this); + if(i==-1) return; + stears.splice(i,1); + delete this; } /** @@ -204,7 +213,7 @@ ${Object.entries(json).map(d => " " + toCssAttr(d[0]) + ": " + d[1] + ";").jo Object.entries(pools).forEach(([k, d]) => { d.lang = lang; }); - this.globalRenderRequest(); + stears.forEach(s=>s.rerenderGlobal()); } /** @@ -587,15 +596,16 @@ export class class_ { */ get render (){ if (!this.#doBuild) return this.#elem; - this.#elem.innerHTML = ""; + let out = []; for (let i = 0; i < this.#build.length; i++) { const elem = this.#build[i]; if (typeof elem == "string" || elem instanceof LanguagePoolString) { - this.#elem.appendChild(document.createTextNode(String(elem))); + out[i] = document.createTextNode(String(elem)); } else { - this.#elem.appendChild(elem.render); - } + out[i] = elem.render; + } } + this.#elem.replaceChildren(...out); return this.#elem; }