aboutsummaryrefslogtreecommitdiffstats
path: root/src/dom.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/dom.js')
-rw-r--r--src/dom.js42
1 files changed, 0 insertions, 42 deletions
diff --git a/src/dom.js b/src/dom.js
index dd15902..45f8a7a 100644
--- a/src/dom.js
+++ b/src/dom.js
@@ -11,45 +11,3 @@ export const css = ([ code] ) => {
return style;
};
-
-const appendChild = (parent, child) => {
- if (child === null || child === undefined || child === false)
- return;
-
- if (Array.isArray(child)) {
- child.forEach((nestedChild) => appendChild(parent, nestedChild));
- } else {
- parent.appendChild(child.nodeType ? child : document.createTextNode(child));
- }
-}
-
-const objectProps = { style: true, dataset: true };
-
-export const createElement = (tag, props, ...children) => {
- if ('function' === typeof tag)
- return tag(props, children);
-
- const element = document.createElement(tag);
-
- for (const [name, value] of Object.entries(props || {})) {
- if (name.startsWith('on') && name.toLowerCase() in window) {
- element.addEventListener(name.toLowerCase().substr(2), value);
- } else if (name === 'css') {
- for (const [prop, val] of Object.entries(value)) {
- element.style.setProperty(prop, val);
- }
- } else if (objectProps[name]) {
- Object.assign(element[name], value);
- } else {
- element.setAttribute(name, value.toString());
- }
- }
-
- for (const child of children) {
- appendChild(element, child);
- }
-
- return element;
-}
-
-export const createFragment = (props, ...children) => children;