// I don't think this line is necessary?
Preact internals #3: some fiddly little bits
Adam Solove

heh — that’s a recent one. Handles this case:

existing: A, B, C, D

new: A, C, D

We hit C in the loop and notice it’s the next node in the existing list, so removing the current node moves it into place. If the current node is elsewhere (eg: at the end of new), it’ll get re-added via insertBefore() later.

Removing the line actually works totally fine, it just can cause an unoptimized diff for single child removals, which are quite common.

Like what you read? Give Jason Miller a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.