KonnorRogers / shadow-dom-testing-library

An extension of DOM-testing-library to provide hooks into the shadow dom
MIT License
98 stars 2 forks source link

Duplicate query results #10

Closed AugV closed 2 years ago

AugV commented 2 years ago

Hi, first of all want to thank you for a great work, this library is something we've been looking for a long time. Now to the topic, it seems that shadow queries are returning duplicate nodes for the same result in some cases. Created a little sandbox to illustrate the issue. This example uses lightDOM, but I have the same problems with web components and shadowDOM.

I saw that you're creating a Set from results in deepQuerySelectorAll() to remove the duplicates, doing the same solution and returning the Set from queryAllByShadow...() methods would solve the issue in question, I believe, unless I'm missing something.

Hopefully that's enough of information, if not, I'll be happy to provide with more :) thanks again.

KonnorRogers commented 2 years ago

I think this is probably an issue of not first checking if the query exists in the light dom. I added this as a test case and will see if I can get it fixed.

KonnorRogers commented 2 years ago

Confirmed. Wrapping the calls in [...new Set(...)] works. I added a test case as well.

KonnorRogers commented 2 years ago

https://github.com/KonnorRogers/shadow-dom-testing-library/pull/11

v1.1.8 should have the fix. Let me know if that works for you.