From 715996aceb4d4dc96410464f60727b98a289be08 Mon Sep 17 00:00:00 2001 From: Josh Kingsley Date: Thu, 30 Oct 2025 13:25:02 +0200 Subject: refactor(web): move selection code --- web/src/html.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'web/src/html.ts') diff --git a/web/src/html.ts b/web/src/html.ts index a118849..3fccda3 100644 --- a/web/src/html.ts +++ b/web/src/html.ts @@ -1,16 +1,16 @@ export function createElement( - tag: string, + tagName: string, ...children: (Node | string)[] ): T; export function createElement( - tag: string, + tagName: string, attrs: Partial, ...children: (Node | string)[] ): T; -export function createElement(tag: string, ...args: any[]) { - const el = document.createElement(tag); +export function createElement(tagName: string, ...args: any[]) { + const el = document.createElement(tagName); if (args[0]?.constructor === Object) { const { dataset, style, ...attrs } = args.shift(); @@ -42,3 +42,9 @@ const h = new Proxy({} as ElementCreator, { }); export default h; + +export function fragment(...children: (Node | string)[]): DocumentFragment { + const fragment = document.createDocumentFragment(); + fragment.append(...children); + return fragment; +} -- cgit v1.2.3