Last active
June 22, 2020 14:44
-
-
Save earthboundkid/45c0b8394f28b2ee3662edfeb80d29ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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