find in render

This commit is contained in:
jusax23 2022-06-10 23:47:39 +02:00
parent 3994dc115f
commit f2822f219f

14
main.js
View file

@ -72,6 +72,7 @@ export class SFrame{
#preRender;
#render;
#call;
#find = {};
#lastRender;
constructor({ preRender, render, call }){
@ -84,8 +85,10 @@ export class SFrame{
}
render(args={}){
this.#lastRender = this.#render({}, args);
this.#lastRender = this.#render({ find: this.#find }, args);
this.#lastRender.render;
for (var member in this.#find) delete this.#find[member];
Object.assign(this.#find, this.#lastRender.find);
return this.#lastRender;
}
@ -94,18 +97,17 @@ export class SFrame{
stear.elem.appendChild(this.#lastRender._);
this.#lastRender._.style.zIndex = layer;
}
var find = (this.#lastRender?.find) ?? {};
return new Promise((res,rej)=>{
this.#call(stear,{
find,
find: this.#find,
render: (args) => {
this.render(args);
for (var member in find) delete find[member];
Object.assign(find, (this.#lastRender?.find) ?? {});
/*for (var member in find) delete find[member];
Object.assign(find, (this.#lastRender?.find) ?? {});*/
if ([...(stear.elem.children)].indexOf(this.#lastRender._) >= 0) stear.elem.removeChild(this.#lastRender._);
stear.elem.appendChild(this.#lastRender._);
this.#lastRender._.style.zIndex = layer;
return find;
return this.#find;
},
resolve: (r,close=true)=>{
if (close&&this.#lastRender&&[...(stear.elem.children)].indexOf(this.#lastRender._) >= 0) stear.elem.removeChild(this.#lastRender._);