Closed pblzd closed 4 months ago
hey @pblzd,, i dont suppose you could share the code? This seems to be an awkward issue to replicate (so i can write a test that this fails, then adding the fix fixes it)
I believe the element is still visible as previously in the code for click()
, we have a scrollIntoView()
view, and it doesn't seem to throw at that so that element must exist. I would need to do some more digging into "quads", to be sure how we might get into a state of our filtering on quads returning an empty array
Ok i've found where we can add the fix, and what the fix is, it's just a matter of replicating it.
Seems to be if the node isn't clickable or isnt a html element
Here's some code to reproduce and verify the issue: https://gist.github.com/pblzd/f005a4ee1d0039b360862c76b6c0b12d.
Thank you for working on this!
Also, one refinement: the error saying quad is not iterable
happens if the element is present but not visible. If the element was removed from the DOM, an error saying TypeError: Cannot read properties of null (reading 'scrollIntoView')
is thrown.
Summary
I'd like to suggest to check if an element is still available in the document when trying to
click()
it. Currently an Error is thrown about its lackingquads
, which is hard to make sense of unless one dives deep into the library and its preparations forclick()
.I stumbled upon this when writing tests for code that re-renders a list of elements, as I was using a reference to an element that got thrown out of the DOM previously to the
click()
. The actual problem is with the calling code, no doubt. But the error message could be more precise and helpful, I think.I'm not sure if empty
quads
is an adequate standalone criterion, and am generally not fluent with the inner workings of a browser, so I'm not comfortable suggesting actual code, sorry!Independent of the outcome of this I'd like to thank you very much for building and maintaining this library, it is very helpful and important!