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
kentcdodds
left a comment
There was a problem hiding this comment.
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.
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.
eps1lon
left a comment
There was a problem hiding this comment.
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
|
@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
fireEventinterface 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
composedproperty totrueif 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
composedproperty is added to existing event initialization definitions where relevant. This allows for events to be composed in any environment that has, at minimum, thewindow.Eventconstructor.Checklist:
docs site N/A
DefinitelyTyped N/A