From 59d83667eda9ecdab05961da81c18f058a8ac065 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 14 Aug 2024 02:43:14 +0900 Subject: refactor(blog/nuldoc): use string value directly instead of `text()` helper for creating text nodes --- vhosts/blog/nuldoc-src/dom.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'vhosts/blog/nuldoc-src/dom.ts') diff --git a/vhosts/blog/nuldoc-src/dom.ts b/vhosts/blog/nuldoc-src/dom.ts index 1147f01b..0358d53b 100644 --- a/vhosts/blog/nuldoc-src/dom.ts +++ b/vhosts/blog/nuldoc-src/dom.ts @@ -79,7 +79,7 @@ export function forEachChildRecursively(e: Element, f: (n: Node) => void) { forEachChild(e, g); } -export function text(content: string): Text { +function makeTextNode(content: string): Text { return { kind: "text", content: content, @@ -90,12 +90,12 @@ export function text(content: string): Text { export function el( name: string, attrs: [string, string][], - ...children: Node[] + ...children: (Node | string)[] ): Element { return { kind: "element", name: name, attributes: new Map(attrs), - children: children, + children: children.map((n) => typeof n === "string" ? makeTextNode(n) : n), }; } -- cgit v1.2.3-70-g09d2