2
0
mirror of https://github.com/esiur/iui.git synced 2025-06-27 09:23:12 +00:00

includeThisElement

This commit is contained in:
2024-07-09 19:25:29 +03:00
parent 8070c96095
commit e6b3023406
4 changed files with 73 additions and 35 deletions

View File

@ -44,19 +44,29 @@ export class IUI {
}, { threshold: [0] });
static async created (element) {
static async created(element, includeThisElement = false) {
for (var i = 0; i < element.children.length; i++) {
let e = element.children[i];
if (e instanceof IUIElement)
await e.created();
await IUI.created(e);
}
// @TODO: this should grow from root to leef
if (includeThisElement && element instanceof IUIElement) {
await element.created();
}
for (var i = 0; i < element.children.length; i++) {
let e = element.children[i];
if (e instanceof IUIElement)
await e.created();
await IUI.created(e);
}
}
static async create(element)
static async create(element, includeThisElement = false)
{
if (includeThisElement && element instanceof IUIElement) {
await element.create();
}
for (let i = 0; i < element.children.length; i++) {
let e = element.children[i];
if (e instanceof IUIElement) {

View File

@ -145,11 +145,11 @@ export default IUI.module(class Repeat extends IUIElement
this.list.push(el);
try {
await IUI.create(el);
await IUI.create(el, true);
IUI.bind(el, false, "repeat",
IUI.extend(this.__i_bindings?.scope,
{index: i, repeat: this}, true));
IUI.extend(this.__i_bindings?.scope,
{index: i, repeat: this}, true));
} catch (ex) {
console.log(ex);
@ -160,7 +160,7 @@ export default IUI.module(class Repeat extends IUIElement
// update referencing
this.__i_bindings?.scope?.refs?._build();
await IUI.created(el);
await IUI.created(el, true);
if (el instanceof IUIElement){
// @TODO should check if the element depends on parent or not