Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit introduces implicit keys to siblings that are being diffed.
This was introduced to solve for the following case:
Before this commit, if the
input
in the above example was focused atthe start, it would lose its focused after the patches were applied
since the
span
would have gotten replaced by theimg
.Now all elements with the same tag are implicitly keyed such that
the diffing algorithm will send up generating patches that will move
elements instead of replace them, when possible.
Note that there is a cost to this, since the longest increasing
subsequence algorithm that we're using to diff keyed siblings is
`O(n log n).
This commit makes it such that
n
will always be the number of childelements, now that all child elements have either an explicit or
implicit key and will all pass through our LCS pass.
Note that the
n
is the number of siblings across the chldren of twodifferent nodes, not the number of nodes in the entire dom tree.
So, for most realistic use cases
n
should be relatively small, sincemost use cases don't have large lists of sibling nodes.