Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
export default function createElement(
tag = "div",
{ classList = [], attrs = {}, children = [], ...props } = {}
) {
let el = document.createElement(tag);
for (let c of classList) {
el.classList.add(c);
}
for (let attr in attrs) {
el.setAttribute(attr, attrs[attr]);
}
Object.assign(el, props);
el.append(...children);
return el;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment