Matt-Esch / virtual-dom

A Virtual DOM and diffing algorithm
MIT License
11.66k stars 779 forks source link

Patch update all subsequent nodes #393

Closed paulocheque closed 8 years ago

paulocheque commented 8 years ago

Example of the image: I have 1 root node with 5 children.

screen shot 2016-04-24 at 2 33 21 am

If I add one node between 1 and 2, the diff returns 1 node of difference, but the patch update the nodes 2, 3, 4 and 5, besides adding the new node between 1 and 2.

Is this an expected behaviour? I am adding unique keys dynamically, but I am not sure if I am missing anything.

This results in a bad performance. If the patch only add the new element, then we have good performance.

ashnur commented 8 years ago

I don't think it should touch that has not changed.

tjconcept commented 8 years ago

Could you simply be needing the "key" property? See this issue: https://github.com/Matt-Esch/virtual-dom/issues/391

paulocheque commented 8 years ago

Yes, it is related to the key and different ids. My mistake probably.