diff options
| author | Josh Kingsley <josh@joshkingsley.me> | 2025-10-30 13:25:02 +0200 |
|---|---|---|
| committer | Josh Kingsley <josh@joshkingsley.me> | 2025-10-30 13:25:02 +0200 |
| commit | 715996aceb4d4dc96410464f60727b98a289be08 (patch) | |
| tree | 876d97664a22246ebecfc25cad1f4b96dee031a0 /web/src/html.ts | |
| parent | 7ef8366bfc43775bf26e71e77bddf31af829dfde (diff) | |
refactor(web): move selection code
Diffstat (limited to 'web/src/html.ts')
| -rw-r--r-- | web/src/html.ts | 14 |
1 files changed, 10 insertions, 4 deletions
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<T extends HTMLElement>( - tag: string, + tagName: string, ...children: (Node | string)[] ): T; export function createElement<T extends HTMLElement>( - tag: string, + tagName: string, attrs: Partial<T>, ...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; +} |
