如何實現一個Virtual DOM算法
- use javascript object to present the structure of dom, and use it to build a real dom tree, then insert to document
- when state updated, recreate a object tree, and then compare old tree and new tree, and record the diff
- use 2.) diff to 1.) real dom tree
2.1. how to compare:
1.Depth-first search for new and old tree, and add unique mark
2.diff type: REPLACE, REORDER, PROPS, TEXT
3.compare list: ex => abcdefghi =>abchdfgij
沒有留言:
張貼留言