business logic, customer communication.
This commit is contained in:
19
lib/functions.js
Normal file
19
lib/functions.js
Normal file
@ -0,0 +1,19 @@
|
||||
function createElement(tagName, className, ...children) {
|
||||
return createElementInit(tagName, className && (element => element.className = className), ...children);
|
||||
}
|
||||
|
||||
function createElementInit(tagName, init, ...children) {
|
||||
const element = document.createElement(tagName);
|
||||
if (typeof init === 'function') {
|
||||
init(element);
|
||||
}
|
||||
if (children.length > 0) {
|
||||
element.append(...children);
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
export {
|
||||
createElement,
|
||||
createElementInit
|
||||
}
|
Reference in New Issue
Block a user