Last active
January 25, 2017 19:41
-
-
Save cacheflow/d200216e659fa0da3ff7901e8fc584eb 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
/** jsx dom */ | |
let dom = (tag, attrs, ...children) => { | |
return {tag, attrs, children} | |
} | |
const list = ( | |
<ul class="list"> | |
<li> Hope </li> | |
<li> This </li> | |
<li> Works </li> | |
</ul> | |
) | |
let createElement = (node) => { | |
if(typeof node == 'string') { | |
return document.createTextNode(node) | |
} | |
let el = document.createElement(node.tag) | |
for(var i = 0; i < node.children.length; i++) { | |
el.appendChild(createElement(node.children[i])) | |
} | |
return el | |
} | |
const app = document.getElementById('app') | |
app.appendChild(createElement(list)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment