ui-lib/lib/functions.js

13 lines
341 B
JavaScript

export function createElement(tagName, init, ...children) {
const element = document.createElement(tagName);
if (typeof init === 'function') {
init(element);
} else if (init != null) {
element.className = init;
}
if (children.length > 0) {
element.append(...children);
}
return element;
}