From f7ea49c88717c0c15835c9024c84a95678836a30 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Fri, 25 Aug 2023 11:38:01 +0530 Subject: refactor: refactors declarations --- src/index.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/index.ts') diff --git a/src/index.ts b/src/index.ts index e5803d2..69d1fea 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,8 +7,8 @@ import { } from './eval' import { extractDeclaration, - DeclarationEval, expressionsToDeclrs, + Declaration, } from './declarations' import { Expr, parse } from './parser' import { match, matchString } from './utils/adt' @@ -68,7 +68,7 @@ export const getPropertyValue = ($element: HTMLElement, prop: string) => { export const getDeclarations = ( $element: HTMLElement, actions: EvalActions, -): Promise> => { +): Promise> => { const value = getPropertyValue($element, PROPERTIES.CHILDREN) return extractDeclaration(value, actions) } @@ -248,7 +248,7 @@ export const handleEvents = async ( } const declarationToElement = ( - declaration: DeclarationEval, + declaration: Declaration, $parent?: HTMLElement, ): { node: HTMLElement; isNewElement: boolean } => { const { tag, id, selectors } = declaration.selector @@ -270,15 +270,16 @@ const declarationToElement = ( }) } - for (const [key, value] of declaration.properties) { - $child?.style.setProperty(key, JSON.stringify(value)) + for (const [key, evalValue] of declaration.properties) { + const value = evalValueToString(evalValue) + $child?.style.setProperty(key, JSON.stringify(value || '')) } return { node: $child, isNewElement } } const createLayer = async ( - declarations: Array, + declarations: Array, $parent: HTMLElement, ) => { const $childrenRoot = -- cgit v1.3.1