From 71aba3df235dc9a8acbee0e33980b30ba4ce44d4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 18 Mar 2023 18:53:05 +0900 Subject: refactor: add components/*.ts for shared components --- nuldoc-src/dom.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'nuldoc-src/dom.ts') diff --git a/nuldoc-src/dom.ts b/nuldoc-src/dom.ts index 626d400..d8f53d7 100644 --- a/nuldoc-src/dom.ts +++ b/nuldoc-src/dom.ts @@ -84,3 +84,24 @@ export function forEachChildRecursively(e: Element, f: (n: Node) => void) { }; forEachChild(e, g); } + +export function text(content: string): Text { + return { + kind: "text", + content: content, + raw: false, + }; +} + +export function el( + name: string, + attrs: [string, string][], + ...children: Node[] +): Element { + return { + kind: "element", + name: name, + attributes: new Map(attrs), + children: children, + }; +} -- cgit v1.2.3-70-g09d2