Last active
September 26, 2015 23:46
-
-
Save joshblack/dbbbcb21216c4a111b06 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
| // Usage | |
| const container = div({ | |
| id: 'foo', | |
| style: { | |
| background: 'black', | |
| width: '100px', | |
| height: '100px' | |
| } | |
| }); |
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 setDOMProps(node, props) { | |
| Object.keys(props).forEach((prop) => { | |
| if (typeof props[prop] === 'object') { | |
| Object.keys(props[prop]) | |
| .forEach((k) => node[prop][k] = props[prop][k]); | |
| } else { | |
| node[prop] = props[prop]; | |
| } | |
| }); | |
| return node; | |
| } | |
| const div = (props) => setDOMProps(document.createElement('div'), props); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment