Do not combine adjacent atomic tags while diffing#4
Merged
Conversation
…tly and add tests for adjacent atomic tags
…patibility with latest versions
… correct output format
sirenevenkii
approved these changes
Jun 23, 2026
sirenevenkii
left a comment
Collaborator
There was a problem hiding this comment.
looks good, let's try it out 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 pull request introduces improvements to how atomic HTML tags (such as
<iframe>) are handled during diff operations, ensuring that each atomic tag is wrapped independently when inserted or deleted. It also adds comprehensive tests to verify this behavior and bumps the package version to reflect these changes.Feature added
The algorithm now gets all the adjacent changes and combine them together into one tag which needs a bit complex css to style later.
We already have a function
isStartOfAtomicTagto determine an atomic tag then in the combine method we stop the array push if it in an atomic tag.UI
Code
Atomic tag diff handling:
js/htmldiff.jsso that each atomic tag is wrapped with its own<ins>or<del>tag, rather than combining adjacent atomic tags or merging them with text. This ensures clearer and more accurate diff output for atomic elements.Testing improvements:
test/diff.spec.jsto verify that adjacent atomic tags are wrapped independently, that atomic tags are not merged with adjacent text, and that non-atomic container tags are handled correctly.test/render_operations.spec.jsto check that atomic tags are wrapped independently in deletion operations.Versioning:
package.jsonfrom1.2.0to1.3.0to reflect the new behavior and improvements.