toy-v-dom

1.0.1 • Public • Published

build

Simple virtual Dom Implementation In ES6 for tutorial purpose. Check the development journal

Install

npm install toy-v-dom

Usage

import { ToyVDom, diff, patch } from 'toy-v-dom'

let oldNode = new ToyVDom('div', { class: 'root', id: 'top'}, [
    new ToyVDom('p', { class: 'son'}, [
        '1'
    ]),
    new ToyVDom('div', { class: 'son'}, [
        new ToyVDom('p', { class: 'grandson '}, ['2'])
    ])
])
oldNode.countDescendants()
let oldDom = oldNode.render()
let newNode = new ToyVDom('div', { class: 'top', id: 'root'}, [
    new ToyVDom('div', { class: 'son', key: '234' }, [
        new ToyVDom('p', { class: 'grandson'}, ['2', '3'])
    ]),
    new ToyVDom('p', { class: 'son', key: '123' }, [
        '2'
    ]),
    new ToyVDom('p', { class: 'son' }, [
        '2', '6'
    ]),
])
let patches = diff(oldNode, newNode)
patch(oldDom, patches)

Readme

Keywords

Package Sidebar

Install

npm i toy-v-dom

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

155 kB

Total Files

15

Last publish

Collaborators

  • jerry153fish