Skip to content

Instantly share code, notes, and snippets.

@dalaidunc
Created October 31, 2018 18:33
Show Gist options
  • Save dalaidunc/d47d6577c961b9df0152c7b102c9ca41 to your computer and use it in GitHub Desktop.
Save dalaidunc/d47d6577c961b9df0152c7b102c9ca41 to your computer and use it in GitHub Desktop.
function h(elemName, props, ...children) {
const elem = document.createElement(elemName);
if (props) {
Object.assign(elem, props);
}
if (children) {
children.forEach(child => {
if (typeof child === 'object') {
elem.appendChild(child);
} else {
elem.appendChild(document.createTextNode(child));
}
});
}
return elem;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment