summaryrefslogtreecommitdiff
path: root/web/src/html.ts
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/html.ts')
-rw-r--r--web/src/html.ts14
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;
+}