-
Notifications
You must be signed in to change notification settings - Fork 468
fix(fireEvent): Set composed property on relevant synthetic events #496
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(fireEvent): Set composed property on relevant synthetic events #496
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Codecov Report
@@ Coverage Diff @@
## master #496 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 22 23 +1
Lines 425 425
Branches 101 101
=========================================
Hits 425 425
Continue to review full report at Codecov.
|
2af860b
to
632cf76
Compare
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.
Love this. Thank you! Just a few notes. Thank you!
c698d97
to
632cf76
Compare
}, | ||
pointerEnter: { | ||
EventType: 'PointerEvent', | ||
defaultInit: {bubbles: false, cancelable: false}, |
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'm deferring to https://w3c.github.io/pointerevents/index.html#attributes-and-default-actions, but I noticed that Chromium-based browsers are non-conformant and set these as composed, while at least Firefox seems conformant. Calling it out in case you have a different preference.
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.
Looks good to me. Kent should still have final approval since I have little experience with shadow dowm
c121049
to
e7f5acd
Compare
e7f5acd
to
13e3d5e
Compare
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.
Super. Thank you!
@all-contributors please add @apalaniuk for code and tests |
I've put up a pull request to add @apalaniuk! 🎉 |
🎉 This PR is included in version 7.1.3 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
What:
When using the
fireEvent
interface to generate synthetic events, if events which are normally composed are dispatched on elements that are within the shadow DOM of a web component, and the listeners expected to handle that event type are registered on the custom element itself (a common configuration), the event listeners will not be triggered as expected, as the event will stop bubbling at the shadow DOM boundary. This deviates from the behaviour of the matching native browser events which are composed, which will propagate outside of the shadow DOM.Why:
This change updates synthetic event init definitions to more closely match their related browser events by setting their
composed
property totrue
if that event type is composed. Without this change, workarounds which couple tests to implementation details are often required in order to find the parent element against which events may be dispatched and handled, rather than dispatching the event against the found element directly and allowing for standard event propagation.How:
A
composed
property is added to existing event initialization definitions where relevant. This allows for events to be composed in any environment that has, at minimum, thewindow.Event
constructor.Checklist:
docs site N/A
DefinitelyTyped N/A