Last active
October 8, 2018 01:09
-
-
Save davidgilbertson/432a0fe2dafb778f0cb56e214ece4f4d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 makeElement(type, props, text) { | |
| const el = document.createElement(type); | |
| Object.keys(props).forEach(prop => { | |
| el[prop] = props[prop]; | |
| }); | |
| const textNode = document.createTextNode(text); | |
| el.appendChild(textNode); | |
| return el; | |
| } | |
| const h1 = (...args) => makeElement(`h1`, ...args); | |
| // and then ... | |
| document.body.appendChild( | |
| h1( | |
| { className: `title` }, | |
| `Hello, world.`, | |
| ) | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment