Last active
June 21, 2020 21:57
-
-
Save gmcabrita/33454bd345172eb382bc030791926b48 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
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