[WICG/webcomponents] Reference Target: How to handle events fired on the reference target by related elements? (Issue #1098)

alice created an issue (WICG/webcomponents#1098)

This was raised by @jakearchibald in https://github.com/whatwg/html/issues/10707#issuecomment-2757756980:

> An interesting case here:
> 
> ```html
> <button popovertarget="component-a">…</button>
> <component-a id="component-a">
>   <template shadowrootmode="closed" shadowrootreferencetarget="inner-thing">
>     <div id="inner-thing" popover>…</div>
>   </template>
> </component-a>
> ```
> 
> As the owner of the button, is it weird that I don't get a `toggle` event on `component-a`, despite the popover being successfully opened?

and https://github.com/whatwg/html/issues/11148#issuecomment-2757687317: 

> Because the problem is `referenceTarget` specific, a solution tailored to `referenceTarget` seems ok. As in, the `command` event (and other related events like popover `toggle`) can flow through retargeted boundaries.
> 
> ```html
> <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 `command` would be seen within `component-b`'s shadow root, since that's where the ultimate target is, but it would also be seen in `component-a`'s shadow root, since it was retargeted from there.
> 
> We'd need to consider cases where retargeting was between multiple shadow roots.
> 
> [We should] work on the referenceTarget-specific issues as part of that feature work. I don't think we should solve this just for command, nor should we end up having to default to composed events everywhere due to referenceTarget.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/1098
You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/issues/1098@github.com>

Received on Monday, 7 April 2025 00:48:59 UTC