This commit is contained in:
jusax23 2022-12-07 20:27:57 +01:00
parent 18e3b13fdc
commit 15a4048730

20
main.js
View file

@ -27,6 +27,8 @@ const pools = {
}; };
const stears = [];
/** Stear class */ /** Stear class */
export class Stear{ export class Stear{
@ -42,6 +44,13 @@ export class Stear{
constructor(elem){ constructor(elem){
this.elem = elem; this.elem = elem;
elem.style.position="relative"; 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]) => { Object.entries(pools).forEach(([k, d]) => {
d.lang = lang; d.lang = lang;
}); });
this.globalRenderRequest(); stears.forEach(s=>s.rerenderGlobal());
} }
/** /**
@ -587,15 +596,16 @@ export class class_ {
*/ */
get render (){ get render (){
if (!this.#doBuild) return this.#elem; if (!this.#doBuild) return this.#elem;
this.#elem.innerHTML = ""; let out = [];
for (let i = 0; i < this.#build.length; i++) { for (let i = 0; i < this.#build.length; i++) {
const elem = this.#build[i]; const elem = this.#build[i];
if (typeof elem == "string" || elem instanceof LanguagePoolString) { if (typeof elem == "string" || elem instanceof LanguagePoolString) {
this.#elem.appendChild(document.createTextNode(String(elem))); out[i] = document.createTextNode(String(elem));
} else { } else {
this.#elem.appendChild(elem.render); out[i] = elem.render;
} }
} }
this.#elem.replaceChildren(...out);
return this.#elem; return this.#elem;
} }