communications app, popup lib
This commit is contained in:
@ -1,19 +1,12 @@
|
||||
function createElement(tagName, className, ...children) {
|
||||
return createElementInit(tagName, className && (element => element.className = className), ...children);
|
||||
}
|
||||
|
||||
function createElementInit(tagName, init, ...children) {
|
||||
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;
|
||||
}
|
||||
|
||||
export {
|
||||
createElement,
|
||||
createElementInit
|
||||
}
|
Reference in New Issue
Block a user