A simple basic implement of virtual-dom algorithm
文章说明:vdom 原理解析与简单实现
实际应用:qcharts
let node1 = (
<div>
<ul>
{[1, 2, 3].map(i => (
<li>{i}</li>
))}
</ul>
</div>
)
let node2 = (
<div className="test">
<ul>
{[...Array(1000).keys()].map(i => (
<li>{i}</li>
))}
</ul>
</div>
)
render(node1, '#app')
document.querySelector('.btn').onclick = () => {
const patches = diff(node1, node2)
patch('#app', patches)
}
MIT