Tram-One / tram-one

🚋 Legacy View Framework For Vanilla Javascript
http://tram-one.io/
MIT License
36 stars 8 forks source link

Handle non-unique elements in Mutation Observer (jest only?) #186

Open JRJurman opened 2 years ago

JRJurman commented 2 years ago

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: https://github.com/Tram-One/tram-one/blob/ce276262871c0476a23a34f5da05f7a9a7e9d99b/src/mutation-observer.ts#L90-L102

We should see this happening in apps after #185 and we see useStores hooks not cleaning up when they have been removed.

JRJurman commented 2 years ago

If this doesn't happen in apps, it is easy enough to work around in the testing, and we should avoid writing unique logic to handle it.