summaryrefslogtreecommitdiff
path: root/src/eval.ts
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2023-08-13 15:34:18 +0530
committerAkshay Nair <phenax5@gmail.com>2023-08-13 15:34:18 +0530
commitc327a1dfc40b834b31c3488020859223f3583b4c (patch)
treee0090a6a49914f528bc4c1f517a329c3c0ae879a /src/eval.ts
parent1f147a779114a641b4abe5e47ac0b05433ec02fb (diff)
downloadcss-everything-c327a1dfc40b834b31c3488020859223f3583b4c.tar.gz
css-everything-c327a1dfc40b834b31c3488020859223f3583b4c.zip
feat: adds add-children and remove-element actions
Diffstat (limited to '')
-rw-r--r--src/eval.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/eval.ts b/src/eval.ts
index 3a4e4f9..3d6734f 100644
--- a/src/eval.ts
+++ b/src/eval.ts
@@ -25,6 +25,8 @@ export interface EvalActions {
url: string
data: FormData | undefined
}): Promise<void>
+ addChildren(id: string, children: Expr[]): Promise<void>
+ removeElement(id: string | undefined): Promise<void>
// calculate ??
}
@@ -126,6 +128,15 @@ const getFunctions = (name: string, args: Expr[], actions: EvalActions) =>
}
},
+ 'add-children': async () => {
+ const id = await evalExpr(args[0], actions)
+ if (id) actions.addChildren(id, args.slice(1))
+ },
+ 'remove-element': async () =>
+ actions.removeElement(
+ (args[0] && (await evalExpr(args[0], actions))) ?? undefined,
+ ),
+
_: () => Promise.reject(new Error('not supposed to be here')),
})