From ca0737e393bbf5c45f688593bbfaf41079a66784 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Fri, 25 Aug 2023 12:14:42 +0530 Subject: feat: h expressions for declaring elements --- src/index.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/index.ts') diff --git a/src/index.ts b/src/index.ts index 69d1fea..bc471ee 100644 --- a/src/index.ts +++ b/src/index.ts @@ -247,10 +247,10 @@ export const handleEvents = async ( } } -const declarationToElement = ( +const declarationToElement = async ( declaration: Declaration, $parent?: HTMLElement, -): { node: HTMLElement; isNewElement: boolean } => { +): Promise<{ node: HTMLElement; isNewElement: boolean }> => { const { tag, id, selectors } = declaration.selector const tagName = tag || 'div' @@ -291,12 +291,17 @@ const createLayer = async ( if (!$childrenRoot.parentNode) $parent.appendChild($childrenRoot) for (const declaration of declarations) { - const { node: $child, isNewElement } = declarationToElement( + const { node: $child, isNewElement } = await declarationToElement( declaration, $childrenRoot, ) $childrenRoot.appendChild($child) + console.log($child.dataset.element, isNewElement, declaration) await manageElement($child, isNewElement) + + if (declaration.children.length > 0) { + await createLayer(declaration.children, $child) + } } } -- cgit v1.3.1