-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
fix(popover): support shadow tree elements lookup #49
fix(popover): support shadow tree elements lookup #49
Conversation
query selector looking for popover attributes will now search within shadow trees recursivly. Closes oddbird#44
@yinonov Thanks for the contribution! I'd love to hear what @keithamus thinks about this before merging. |
I'm a little bit concerned looking through the query selector library, as it looks like it might cause slowdowns on pages with lots of shadow roots. It also looks like it won't work on closed shadowRoots. Given we know we only want to interact with elements that have a To use a MutationObserver we could patch |
given the lack of broad support for declarative shadowRoots, can the |
It might be worth looking into how declarative shadow roots are assigned to see if it would significantly alter the architecture. Having said that I have a hunch it won't be easy and may require extensive modifications to multiple APIs, and so we might be better off ignoring them for now. Closed shadow roots are only accessible via I think it's quite reasonable to add "does not work with declarative shadow Dom" to the list of caveats for now. That means the only mechanism for creating shadow roots is with |
notes to self:
will any shadowRoots within shadowRoots remove parent observation? |
as this seem to be bigger than the initial expectation, I'd ask for a short review before moving forward. The plan is to move new code to a class that handles all observation of document or shadowRoot. removed the |
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.
This looks like a very nice implementation. I just have one small concern about nested popovers that happen during a mutation.
I keep getting |
@yinonov I've hit that recently too, and it seems to be inconsistent for me -- it passes once, then times out. Something in the connection between playwright and esbuild, but I haven't had time to dig into it yet. |
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.
This looks really good to me now 👍
so is it possible to at least run tests in CI pre-merge? |
We could merge this into a branch and allow CI to run there before merging into I can't reproduce the timeout locally, only occasionally on CI. Locally, can you run |
thanks, that did it for now. resolving failures... |
I think there's a way we can modify the |
I think it might be this line stopping them running:
I believe this means they’ll only run on a PR that gets reopened. |
facing an issue with playwright locator not supporting close mode shadowRoot tests won't pass unless host.attachShadow({ mode: 'closed' }); is set to we still want to ensure close shadowRoots are tested, don't we? |
I don't see a way around this blocker unless heavily extending the testing environment. don't feel right. are we ok with the compromise of testing against |
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.
Functionality looks good! A few minor changes, then I think this is ready to merge.
Co-authored-by: Jonny Gerig Meyer <jonny@oddbird.net>
Co-authored-by: Jonny Gerig Meyer <jonny@oddbird.net>
Co-authored-by: Jonny Gerig Meyer <jonny@oddbird.net>
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.
🚀
@jgerigmeyer @keithamus thank you for all the support! |
@yinonov Thanks for your contribution! I'll make a new release today or Monday. |
Published v0.0.5 |
querySelector looking for all
[popover]
attributes in a document will now pierce withinshadow trees recursively.
this introduces a use of a package query-selector-shadow-dom.
What bugs me with this solution is that it the package
querySelectorAllDeep
method doesn't operate from a specific element, and rather the document element, thus removes the explicit query fromownerDocument
of the polyfill (might be good to raise a request for the team query-selector-shadow-dom/issues).this probably has little effect in browsers, as, commonly,
ownerDocument
will always point at the document element.would love to hear maintainers' thoughts on this...
Closes #44
issues to resolve -
connectedCallback
instead. can the static methodobservedAttributes
assist to trigger popover attributes change?https://github.com/yinonov/popover-polyfill/blob/8bac7a2d5b74428c75ac08696ff197747722c72d/README.md#L29-L33
?
effectedPopover
and return a wrong element. should relations between popover button and its control NOT bleed out of sameownerDocument
?