Created
August 15, 2017 09:40
-
-
Save mykolaharmash/b4f431081d6b550492eb7f8df10f8573 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 clientRender () { | |
let root = document.body | |
function createElement (name, attrs, children) { | |
let element = document.createElement(name) | |
Object.keys(attrs).forEach((attrName) => { | |
element.setAttribute(attrName, attrs[attrName]) | |
}) | |
children.forEach((contentItem) => { | |
element.appendChild(contentItem) | |
}) | |
return element | |
} | |
let title = createElement('h1', {}, [document.createTextNode('Client Page')]) | |
let component = createElement('div', { class: 'component' }, [ | |
createElement('ul', {}, [ | |
createElement('li', {}, [document.createTextNode('one')]), | |
createElement('li', {}, [document.createTextNode('two')]), | |
createElement('li', {}, [document.createTextNode('three')]) | |
]) | |
]) | |
let rootContent = [title, component] | |
rootContent.forEach((childNode) => { | |
root.appendChild(childNode) | |
}) | |
} | |
clientRender() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment