Reliably generate mutations while the snapshot is iterating #61
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.
Reliably generate mutations while the snapshot is iterating in order to test rarely occurring problems. Have added what I believe should be the correct parsing, on the assumption that the DOM changes will subsequently be correctly picked up by mutation events.
a
&b
demonstrate different outcomes because of the freezing of childNodes infor (const childN of Array.from(n.childNodes))
— I'm not sure if there's a better way to iterate over child nodes (I imagine this freezing was intentional)d
takes this further to show that it should not be possible to iterate to the#d3
elemente
test case is the important one as it demonstrates that the snapshot can produce duplicate nodes, in this case#a1
appears twice in the outputI authored #60 assuming there was something similar to the
e
test case going on.But maybe a better solution would be to ensure all
__sn
attributes are wiped before the start of a snapshot, and ignore any nodes that already have a__sn
assigned if we encounter them in the DOM walk, as presumably they have a lower id from earlier in the walk.Node: The code modifications in snapshot.ts to get these tests to work would need to be removed or somehow only targetted to a special test build.
I'd like to get further input into this before proceeding on fixes for the test case failures I've created in this pull request!