diff options
author | Joris | 2023-02-13 15:25:56 +0100 |
---|---|---|
committer | Joris | 2023-02-13 21:34:38 +0100 |
commit | ffca3dfb15f37999d2b751c5b62a90ead65201a3 (patch) | |
tree | 62f2b0429ea6f8aaa328d41da7b623439142e75b /src/lib/h.ts | |
parent | a1960c7e10691e460b835446bb358c27e971fba8 (diff) |
Use rx to update the view
Diffstat (limited to 'src/lib/h.ts')
-rw-r--r-- | src/lib/h.ts | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/src/lib/h.ts b/src/lib/h.ts deleted file mode 100644 index 8b1abf3..0000000 --- a/src/lib/h.ts +++ /dev/null @@ -1,34 +0,0 @@ -type Child = Element | Text | string | number - -export default function h( - tagName: string, - attrs: object, - ...children: Child[] -): Element { - const isSvg = tagName === 'svg' || tagName === 'path' - - let elem = isSvg - ? document.createElementNS('http://www.w3.org/2000/svg', tagName) - : document.createElement(tagName) - - if (isSvg) { - Object.entries(attrs).forEach(([key, value]) => { - elem.setAttribute(key, value) - }) - } else { - elem = Object.assign(elem, attrs) - } - - for (const child of children) { - if (typeof child === 'number') - elem.append(child.toString()) - else - elem.append(child) - } - - return elem -} - -export function classNames(obj: {[key: string]: boolean }): string { - return Object.keys(obj).filter(k => obj[k]).join(' ') -} |