Skip to content

Instantly share code, notes, and snippets.

@gmcabrita
Last active June 21, 2020 21:57
Show Gist options
  • Save gmcabrita/33454bd345172eb382bc030791926b48 to your computer and use it in GitHub Desktop.
Save gmcabrita/33454bd345172eb382bc030791926b48 to your computer and use it in GitHub Desktop.
function $e(tag='div', props={}, children=[]){
let element = document.createElement(tag);
Object.assign(element, props);
element.append(...children);
return element;
}
// With `elem.append(...children)` - with the added benefit that plain strings passed to .append() get turned into text nodes automatically, so you probably don't need $t any more.
var $t=document.createTextNode.bind(document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment