diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-08-25 11:38:01 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-08-25 11:38:01 +0530 |
| commit | f7ea49c88717c0c15835c9024c84a95678836a30 (patch) | |
| tree | 0eb5f9eac3729fec96c7257df24cde416efbdb46 /src/index.ts | |
| parent | 8a987f6c3cffd37437adca6c133fab989233a308 (diff) | |
| download | css-everything-f7ea49c88717c0c15835c9024c84a95678836a30.tar.gz css-everything-f7ea49c88717c0c15835c9024c84a95678836a30.zip | |
refactor: refactors declarations
Diffstat (limited to '')
| -rw-r--r-- | src/index.ts | 13 |
1 files changed, 7 insertions, 6 deletions
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<Array<DeclarationEval>> => { +): Promise<Array<Declaration>> => { 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<DeclarationEval>, + declarations: Array<Declaration>, $parent: HTMLElement, ) => { const $childrenRoot = |
