-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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: Use composedPath
to find anchor elements
#2769
feat: Use composedPath
to find anchor elements
#2769
Conversation
🦋 Changeset detectedLatest commit: 254e3f5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
It would be great if you can add a test for web components as well!
@bluwy Could you help me figure out where/how to add the test? |
I think under |
Here is a first pass. I based the test on this. Please let me know if I can improve it. |
thank you! this looks good. any chance you could add a changeset, so that this triggers a version bump? for future reference it's useful to keep the pull request template in the comment as it includes a checklist/instructions for stuff like this |
The client-side router registers event handlers on mouse movements and clicks that search anchor elements in an event's target's ancestors to perform prefetching or routing. The current implementation uses `parentNode` which "skips" anchor elements in shadow doms. This change searches instead the `event.composedPath()`, which includes nodes in open shadow trees.
c8cdb97
to
254e3f5
Compare
I included a changeset and added back the PR template. Excited for my first contribution to a project a love so dearly! Also, congrats on the big news from yesterday! 👏 |
https://developer.mozilla.org/en-US/docs/Web/API/Event/composedPath Using APIs like this would prevent us from (eventually) supporting IE11 without a prototype-modifying polyfill. (I haven't checked whether one exists for this particular API.) Would it be worth it to include a fallback here so that when we do support IE11 and other differential legacy build stuff, all those builds will have to do is transpile JS and include a couple of polyfills for things like It's also possible that that ship has already sailed and we're already using a bunch of APIs like this all over the place, and we'll just have to cross that bridge when we get to #12. |
I'd personally lean towards documenting the polyfill requirement. Or better still, injecting polyfills for stuff like this if a |
For this particular situation, given that IE11 doesn't support the Shadow DOM, we could also check if |
@andreavaccari I think that's the discussion we're having now, whether to add those extra bytes of code or not. Seems like the consensus is to document it, so I'm putting my approval on this. Thanks for adding this feature! |
thanks! |
Closes #2768
Changes
parentNode
which "skips" anchor elements in shadow doms.event.composedPath()
, which includes nodes in open shadow trees.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpx changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0