3 ms·
This is the way. In addition to `$` and `$$`, I usually have `$h` for creating elements: /** * @param {string} name * @param {HTMLElement.prototy
by abdusco 4y ago
This is the way. In addition to `$` and `$$`, I usually have `$h` for creating elements:
/**
* @param {string} name
* @param {HTMLElement.prototype} props
* @param {Array<HTMLElement|string>} children
* @return HTMLElement
*/
function $h(name = 'div', props = {}, children = []) {
const el = document.createElement(name);
Object.assign(el, props);
el.append(...children);
return el;
}