diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-08-18 11:02:34 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-08-18 11:04:04 +0530 |
| commit | 18a60b5f53cdff3f2b9c8cecd3f34cadc6f08865 (patch) | |
| tree | 95d4d306f45f201492d07ac9621b7d05ac185593 /src/eval.ts | |
| parent | c8cdbd8d6669b1eb1a5d2389893c2460bef73d76 (diff) | |
| download | css-everything-18a60b5f53cdff3f2b9c8cecd3f34cadc6f08865.tar.gz css-everything-18a60b5f53cdff3f2b9c8cecd3f34cadc6f08865.zip | |
feat: call arbitrary method on node + added :parent selector
Diffstat (limited to 'src/eval.ts')
| -rw-r--r-- | src/eval.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/eval.ts b/src/eval.ts index 445cb8f..aba31df 100644 --- a/src/eval.ts +++ b/src/eval.ts @@ -31,6 +31,11 @@ export interface EvalActions { }): Promise<void> addChildren(id: string, children: Expr[]): Promise<void> removeElement(id: string | undefined): Promise<void> + callMethod( + id: string | undefined, + method: string, + args: EvalValue[], + ): Promise<void> // calculate ?? } @@ -154,6 +159,14 @@ const getFunctions = (name: string, args: Expr[], actions: EvalActions) => { actions.removeElement( (args[0] && (await evalExpr(args[0], actions))) ?? undefined, ), + call: async () => { + const [id, method, ...methodArgs] = await Promise.all( + args.map(a => evalExpr(a, actions)), + ) + if (id && method) { + actions.callMethod(id, method, methodArgs) + } + }, _: () => Promise.reject(new Error('not supposed to be here')), }) |
