fix: diff WC respecting internal DOM modifications #18
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.
Fixes brisa-build/brisa#611
The problem that happened is that when doing diffing of the WC made 2 steps, first, it made an insert (L176), and after adding the node, it entered in line 188 and made a diffing with the
newNode
when theinsertedNode
was already a clone of the new one, but of course, the new one did not have the internal change of the DOM modified by the WC (this.setAttribute
), then it is as if it had not been applied.https://github.com/aralroca/diff-dom-streaming/blob/0169dc1c9315099f340f7d60599e9fecf201eaca/src/index.ts#L173-L188
Example of WC:
This PR fix the removal of
data-connected
in this extra unnecessary step.Removing this code, all the tests continue passing and it solves the new tests that I have added.
CC: @AlbertSabate