Closed WebReflection closed 4 years ago
P.S. the proof for mutations happening even if a node doesn't leave the tree is here https://github.com/luwes/js-diff-benchmark/issues/7#issuecomment-615652697
Following the table using the before
element:
feel free to merge too, I added you as a collaborator.
I know, but I'm used to have other people eyes on my PR when it's more than just me on a repo 😉
As discussed in https://github.com/luwes/js-diff-benchmark/issues/7#issuecomment-615875584, the way we are counting operations does not reflect the real-wolrd amount of DOM mutations triggered through the nodes:
appendChild
is 1 up to 2 mutations, if the node was already live (moved)insertBefore
is 1 up to 2 mutations, if the node was already live (moved)removeChild
is always only 1 mutationreplaceChild
is 2, up to 3 mutations if the node was already live (moved)Accordingly, the counting should change too, specially the swap and the shuffle, as most libraries technically trigger similar amount of observable mutations on the tree:
removeChild
followed by aninsertBefore
, which sum is 2, orreplaceChild
which counts as either 2 or 3The table better reasons, and explain, why udomdiff performs similarly, if not faster, than other libraries when it comes to the shuffling example