diff options
author | Joris | 2025-04-19 12:36:38 +0200 |
---|---|---|
committer | Joris | 2025-04-19 12:38:24 +0200 |
commit | 632eef6424d8dc8d40c2906177892697679e7b85 (patch) | |
tree | 48d9cd60e9e96eab810b5f7bb3c7b1fa79e0438f /src/lib/h.ts | |
parent | 063d8ef9eaf874a941f4459e831057dd0a1b7ddd (diff) |
Add ZIG server
Diffstat (limited to 'src/lib/h.ts')
-rw-r--r-- | src/lib/h.ts | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/src/lib/h.ts b/src/lib/h.ts deleted file mode 100644 index 7e93311..0000000 --- a/src/lib/h.ts +++ /dev/null @@ -1,31 +0,0 @@ -type Child = Element | Text | string | number - -export type Children = Child[] - -export function h(tagName: string, attrs: object, ...children: Children): Element { - let elem = document.createElement(tagName) - elem = Object.assign(elem, attrs) - appendChildren(elem, ...children) - return elem -} - -export function s(tagName: string, attrs: object, ...children: Children): Element { - let elem = document.createElementNS('http://www.w3.org/2000/svg', tagName) - Object.entries(attrs).forEach(([key, value]) => elem.setAttribute(key, value)) - appendChildren(elem, ...children) - return elem -} - -function appendChildren(elem: Element, ...children: Children) { - for (const child of children) { - if (typeof child === 'number') - elem.append(child.toString()) - else - elem.append(child) - } -} - -export function concatClassName(attrs: any, className: string): object { - const existingClassName = 'className' in attrs ? attrs['className'] : undefined - return { ...attrs, className: `${className} ${existingClassName}` } -} |