Couldn't this be more efficient by elimination old updates to children of newer updates? Say node B is a child of node A:
A
\
B
Currently, the coalesce function would do:
coal(prev[B], new[A]) = [B, A];
But since A already includes updates to B, the older B update is not necessary. You could just do:
coal(prev[B], new[A]) = [A]; because isPrevChildOfCurrent(B, A) == true
I would think this additional search would be more efficient than applying extra, unneeded DOM updates in the browser.
Yes, you are right. I thought about implementing the algorithm you mention above. There were a few things that stopped from doing it that way:
a) It can potentially introduce a lot of DOM traversals when coalescing over a larger set of elements.
b) Occurrences of having newer element updates that include older element updates is quite small.
c) Code becomes more complex thus more difficult to maintain.
d) The added increased traffic due to older included updates is relatively small.