-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Support for shadow dom #30
Comments
Hmm... isn't the point of Shadow DOM is to hide it away from the parent container? I'll have to think about this for now. Will open it up for feedback from others who've hopefully had more experience. Thanks for the suggestion! |
Yes, the point is encapsulation but that doesn't mean event delegation should not work. It is true that you need to properly configure events your components manually dispatch if you want them to exit shadow root boundaries You can read more about it here https://developers.google.com/web/fundamentals/web-components/shadowdom#events Thanks for considering. Edit: a fallback may be needed for browsers that don't support |
Please consider implementing this feature as navaid does not work with Shadow DOM (and libraries like LitElement that uses Shadow DOM by default) without it. I added @isidrok's code to navaid's You might also want to take a look at the relevant pull request from Page.js . I think this feature would be really useful as Shadow DOM is supported in all modern browsers and its usage is rising. Thanks |
Yes please! :) It's hard to find a simple and robust router that supports Shadow DOM (Web Components) and By adding a few lines of code |
FWIW, I'll maintain a forked version that supports shadow-dom anchor links, where the only change is from this: Line 53 in b2b105a
to this: var x = e.composedPath, x = e.path || x && x() || [e.target],
x = x[0].closest('a'), y = x && x.getAttribute('href'); Install with:
|
Intercepting clicks made on anchors inside shadow roots looking for the anchor closest to the event target doesn't work since events are re-targeted to the shadow root host element.
The anchor can be found in the event path with the following code:
Note that this will only work for shadow roots configured with mode set to open since elements inside closed ones don't appear in the event path.
Can submit a PR if you agree with the proposed change
The text was updated successfully, but these errors were encountered: