-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Summary
While writing the tests for #185, it was found that sometimes the mutation observer will get a duplicate of an element (usually when it is now catching up to multiple events that happened in the app).
I believe this is something that only happens in tests, and possible a side-effect of how jest / jsdom / testing-library work.
If that isn't the case, we should update the logic here:
tram-one/src/mutation-observer.ts
Lines 90 to 102 in ce27626
| new MutationObserver((mutationList) => { | |
| // cleanup orphaned nodes that are no longer on the DOM | |
| const removedNodesInMutation = (mutation: MutationRecord) => [...mutation.removedNodes]; | |
| const removedNodes = mutationList.flatMap(removedNodesInMutation).flatMap(childrenComponents); | |
| removedNodes.forEach(clearNode); | |
| // call new effects on any new nodes | |
| const addedNodesInMutation = (mutation: MutationRecord) => [...mutation.addedNodes]; | |
| const newNodes = mutationList.flatMap(addedNodesInMutation).flatMap(childrenComponents); | |
| newNodes.forEach(processEffects); | |
| }); |
We should see this happening in apps after #185 and we see useStores hooks not cleaning up when they have been removed.
Metadata
Metadata
Assignees
Labels
No labels