Created
June 21, 2020 17:39
-
-
Save jamespantalones/d0851ab9ef1aaffa4c776cff07f17c85 to your computer and use it in GitHub Desktop.
Tiny DOM tool
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
// ------------------------------------------------ | |
// Tool | |
// ------------------------------------------------ | |
const T_ = document.createTextNode.bind(document); | |
function E_(t = 'div', p = {}, c = []) { | |
let el = document.createElement(t); | |
Object.assign(el, p); | |
el.append(...c); | |
return el; | |
} | |
// ------------------------------------------------ | |
// Usage | |
// ------------------------------------------------ | |
const App = E_('section', { id: 'thing', className: 'test2' }, [ | |
E_('p', {}, [T_('some thing77')]), | |
]); | |
document.body.append(App); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment