-
Notifications
You must be signed in to change notification settings - Fork 2.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
Should the command
event really be composed
?
#11148
Comments
Additionally, what the command |
Yeah this seems bogus. Pretty much only UI events are meant to be composed. |
We had a discussion about this in the matrix here: https://matrix.to/#/!AGetWbsMpFPdSgUrbs:matrix.org/$_lNM7kzsK1cY9w4eLFNM0dlDxN_IU2xqlvuXR3UaWh0 @smaug---- commented:
to which I replied:
|
It seems really weird to me that the command would compose whereas the |
(fwiw I think |
@smaug---- I agree with @keithamus's original thoughts on this. It's ok to know a custom element was clicked (and other mouse/keyboard actions), because we don't want to create dead zones like you get with iframes, so it's right that those events compose. But, parent roots shouldn't know about specific interactions within the shadow root, unless the shadow root chooses to expose them. If a user agent chose to implement It feels a bit like how If I had a button in my shadow root that issued a command to open a popover, it feels like that should be internal by default, and something I'd expose via custom events if I wanted to expose it. |
I'd expect command event to work (in the future) with something similar to referenceTarget, and in such case propagating the command out of shadow DOM would very much make sense - someone outside the shadow DOM is triggering the command and that someone should be able to see the event. Do we need some finer grain API here, that in some cases commands would stay within a shadow DOM and in some cases they wouldn't? |
Ohh, so you're talking about a case where the button is in the light DOM, but is redirected into a shadow DOM by some new feature like My thoughts on this:
But, the current behaviour, where all command events leak, doesn't seem right. If |
Should we remove composition here then look for ways to deal with the rarer cases where the commends should leak out of shadow roots? |
Cc @keithamus I'm not sure what the process for this would be on the chrome side (as it's shipped) but I'm neutral on this topic so if the consensus ends up being that we should remove it then I'd be happy to update the WebKit implementation. Cc @mfreed7 for Google's thoughts too |
I don't think the consensus is that we should remove composed, since that would break command handling from other subtrees. Do we need similar event propagation logic what events with .relatedTarget have? I could live with that. |
Can you cover the use-cases in a bit more detail here? It seems like:
<button command="--foo" commandFor="custom-thing">…</button>
<custom-thing id="custom-thing">…</custom-thing> In the above case, if the implementation of
I don't think we should make the general usages weird/leaky just because of Because the problem is <component-a>
<template shadowrootmode="closed">
<button command="--foo" commandFor="component-b">…</button>
<component-b id="component-b">
<template shadowrootmode="closed" shadowrootreferencetarget="inner-thing">
<div id="inner-thing"></div>
</template>
</component-b>
</template>
</component-a> In the example above, the We'd need to consider cases where retargeting was between multiple shadow roots. Either way, it feels like we should remove |
@smaug---- I guess you still think that (it's absolutely not a hill I want to die on, so I'm happy to defer to what you think) |
What is the issue with the HTML Standard?
https://html.spec.whatwg.org/multipage/form-elements.html#attr-button-command-custom
Step 5.5 fires a
command
event withcomposed
set to true, meaning it leaks in/out of shadow boundaries.Given that
commandFor
can only point to elements in the same root, it seems like this feature is encapsulated within a root, but then thecomposed
event crosses root boundaries, which seems odd.For example, if, within a shadow root, I have a button which has a custom
command
pointing to another element in the shadow root, why should things outside that root get to see what thecommand
is, and cancel them? This seems like a leak of my (the owner of the shadow root) implementation details.cc @mfreed7 as you might know the background here.
The text was updated successfully, but these errors were encountered: