An easy-to-use solution to reduce manual DOM manipulation.
;// use `h` to create a virtual dom treevar tree =;// use `create` generate a real dom from virtual dom.var root = ;// generate another different virtual dom treevar newTree =;// use `diff` diff two virtual dom trees and get patchesvar patches = ;// use `patch` apply patches to real dom;
You can checkout an another example in example folder.
You should always provide a unique
key property for each child in array(just like ReactJS's keyed children) for
hg-virtual-dom to reorder children instead of replacing the whole list when perform diff algorithm.
var root =;var newRoot =;// ensure `patches` is minimumvar patches = ;