본문 바로가기

Virtual DOM 2

web/javascript by 낼스 2019. 7. 12.
# Virtual DOM 2 ##### [source : https://jsfiddle.net/softm/cgqnzewm/](https://jsfiddle.net/softm/cgqnzewm/) ```html
``` ```javascript /** @jsx h */ function h(type, props, ...children) { return { type, props, children }; } function createElement(node) { if (typeof node === 'string') { return document.createTextNode(node); } const $el = document.createElement(node.type); node.children .map(createElement) .forEach($el.appendChild.bind($el)); return $el; } const a = (
  • item 1
  • item 2
); const $root = document.getElementById('root'); $root.appendChild(createElement(a)); ```

'web > javascript' 카테고리의 다른 글

Write your Virtual DOM 2: Props & Events  (0) 2019.07.12
Virtual DOM 3  (0) 2019.07.12
Virtual DOM 1  (0) 2019.07.12
Javascript Prototype to json  (0) 2019.07.12
Javascript Promise(프로미스는)  (0) 2019.07.12

댓글