-
Notifications
You must be signed in to change notification settings - Fork 295
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
Composed and non bubbling event semantic dispatched in shadow tree #742
Comments
So the problem is that we created events that only have a capture phase from the view of certain trees. I think what's needed here is these changes:
This would make step 14 read:
cc @whatwg/components (As for composed, it affects building the event's path and that's it. It seems like you mostly didn't observe the event because you didn't have capture listeners.) |
Those changes look reasonable to me. Thanks for the details @annevk. |
As @pmdartus mentioned, the proposed changes look good, but I will like to get some clarification on why the current behavior was chosen in the first place. We discovered the issue described here while trying to test our synthetic shadow dom polyfill, and we were surprised by the behavior of all browsers. Why all composed events dispatched on the host elements in the event path regardless if the event bubbles or not? Seems counterintuitive, and leak internal implementation details of the component. |
@caridy events have four phases: none, capturing, at target, and bubbling. Capturing and at target are always performed. If we did not perform at target for a composed event, it would actually leak that there was a component as the target for an event we could observe during capturing was not in our tree. (I realize this is the opposite of what you suggest, but it's unclear to me how you're arriving at your conclusion.) |
Maybe we need |
@rniwa that is what composed is for. By default an event's path doesn't cross the shadow boundary (except from something slotted into a shadow tree, but that's different). |
@annevk : oh, that's a good point. If the composed is set to false, we wouldn't have this issue. |
here is a very concrete example of the problem: <div>
#shadowRoot
<div>
<x-foo> If component From the technical point of view, the leaking aspect of it is pretty bad because the only way you have to prevent an event from leaking is by listening for it at the host level (during construction time), and stop immediate propagation, and you have to do so for all events dispatched by any of your child components in order to control the leakage, and still, there is a possibility that the host was upgraded after a listener for the event was added by someone else, in which case, you have no ways to prevent the leakage. |
@caridy if you use |
This fixes a regression from #686. Tests: various tests were failing because of this. web-platform-tests/wpt#16307 aligns the remaining failing test with the new model. Fixes #742.
Fix at #750. |
This fixes a regression from #686. Tests: various tests were failing because of this. web-platform-tests/wpt#16307 aligns the remaining failing test with the new model. Fixes #742.
WebKit test added in https://trac.webkit.org/r236002. Helps with whatwg/dom#742.
…ac.webkit.org/r236002 for whatwg/dom#742, a=testonly Automatic update from web-platform-tests DOM: more shadow tree event dispatching tests WebKit test added in https://trac.webkit.org/r236002. Helps with whatwg/dom#742. -- wpt-commits: 151e1e4165dab9d279252be5b2ca64c39b9a4a56 wpt-pr: 16358
…ac.webkit.org/r236002 for whatwg/dom#742, a=testonly Automatic update from web-platform-tests DOM: more shadow tree event dispatching tests WebKit test added in https://trac.webkit.org/r236002. Helps with whatwg/dom#742. -- wpt-commits: 151e1e4165dab9d279252be5b2ca64c39b9a4a56 wpt-pr: 16358
WebKit test added in https://trac.webkit.org/r236002. Helps with whatwg/dom#742.
…ac.webkit.org/r236002 for whatwg/dom#742, a=testonly Automatic update from web-platform-tests DOM: more shadow tree event dispatching tests WebKit test added in https://trac.webkit.org/r236002. Helps with whatwg/dom#742. -- wpt-commits: 151e1e4165dab9d279252be5b2ca64c39b9a4a56 wpt-pr: 16358 UltraBlame original commit: 39ff6aa7f78129bda90cf2ee5a273233f2c666e2
…ac.webkit.org/r236002 for whatwg/dom#742, a=testonly Automatic update from web-platform-tests DOM: more shadow tree event dispatching tests WebKit test added in https://trac.webkit.org/r236002. Helps with whatwg/dom#742. -- wpt-commits: 151e1e4165dab9d279252be5b2ca64c39b9a4a56 wpt-pr: 16358 UltraBlame original commit: 39ff6aa7f78129bda90cf2ee5a273233f2c666e2
…ac.webkit.org/r236002 for whatwg/dom#742, a=testonly Automatic update from web-platform-tests DOM: more shadow tree event dispatching tests WebKit test added in https://trac.webkit.org/r236002. Helps with whatwg/dom#742. -- wpt-commits: 151e1e4165dab9d279252be5b2ca64c39b9a4a56 wpt-pr: 16358 UltraBlame original commit: 39ff6aa7f78129bda90cf2ee5a273233f2c666e2
What is the expected behavior for a composed and non-bubbling event when dispatched inside a shadow tree?
When an event listener is attached to the host element, and a composed and non-bubbling event is dispatched within a shadow tree, the listener attached on the host element is invoked. Here is an example: https://jsfiddle.net/pmdartus/6ft9gkc4/7/
This behavior is consistent on all the browsers implementing shadow DOM.
As far as I understand the recent changes made to the dispatch event algorithm (#686), the behavior changed and now the event will only invoke the host element event handler if the event bubbles (step 14). Is it the new expected behavior, or did I missed something?
Regardless of the outcome of this question, I think it worth adding more details to the non-normative section about
composed
.The text was updated successfully, but these errors were encountered: