JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q28663F
  • License MIT

simple virtual-dom

Package Exports

  • anduin

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (anduin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Anduin

A simple virtual-dom

Install

$ npm install -S anduin

Example

import { h, diff, patch } from 'anduin'

// use `h(tagName, [attribute], children)` to create a virtual dom tree.
let vdom1 = h("div", {}, [
  h("h1", {}, 0),
  h("button", { }, "-"),
  h("button", { }, "+"),
  h("ul", {}, [
    h("li", { key: 'a' }, 'a'),
    h('li', { key: 'b' }, 'b'),
    h("li", { key: 'c' }, 'c'),
    h('li', { key: 'd' }, 'd'),
  ])
])

let vdom2 = h("div", {}, [
  h("h1", {}, 1),
  h("button", { props: 'hashKey' }, "-"),
  h("button", { }, "+"),
  h("ul", {}, [
    h('li', { key: 'f' }, 'f'),
    h("li", { key: 'a' }, 'a'),
    h('li', { key: 'b' }, 'b'),
    h('li', { key: 'd' }, 'd'),
    h("li", { key: 'c' }, 'c'),
    h('li', { key: 'e' }, 'e'),
  ])
])

// generate a real dom from virtual dom.
let root = vdom1.render()

document.body.appendChild(root)

// diff two virtual dom trees and apply patches to real dom
patch(root, patches, root)

You can checkout full codes in example folder.

Reference

snabbdom