-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add visible options to toMatchElement config #208
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is pretty "fragile", we don't have another option to detect if an element is visible or not?
use selector is an easy way, but If we want to check the element not indeed appear, check that display and visibility are incomplete. I will confirm if puppeteer will detect |
@xiaoyuhen does it work when the element has a class that has a "display: none"? If not, then it is not usable. |
Yeah, it works. i update the test case. |
Have you guys considered using the Intersection Observer API for this case? https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API |
@Aaron-Pool why not, if it works better, it is good for me. |
@neoziro I can't say with 100% certainty that it's "better". But I have used it before, and it seems pretty reliable and performant. Also, considering the MDN docs start with "Historically, detecting visibility of an element [...] has been a difficult task for which solutions have been unreliable", it seems like it was introduced for purposes just like these 👍 |
@neoziro @xiaoyuhen Actually, the more I look at it, I'm curious as to why you guys decided to use You guys might have a perfectly good reason for doing so, just curious what it was 👍 |
@xiaoyuhen tests are not passing, could you fix it please? |
@xiaoyuhen I think the class strategy does not work |
@neoziro |
thanks for your suggestion, we cant use Intersection Observer API is a good solution, but it's too heavy, I choose the way same with puppeteer. |
it looks like works well now, could you please review this pr again? |
Good for me thanks! |
Summary
Add visible options to toMatchElement config,.
wait for element to be present in DOM and to be visible, i.e. to not have
display: none
orvisibility: hidden
CSS properties. Defaults tofalse
.see #207
Test plan
see test case