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

alice left a comment (WICG/webcomponents#1098)

#### button with `popoverTarget` _inside_ of shadow root with reference target

From 

```html
<x-popover id="popover">
  <template shadowRootMode="open" shadowRootReferenceTarget="container">
    <style>
      #container {
        /* completely encapsulated styles for the popover */
      }
    </style>
    <button popovertarget="popover">Toggle</button>
    <div id="container" popover>
     Popover content.
    </div>
  </template>
</x-popover>
```

(Steps 1-11 are the same as above.)
12. 🆕 When [a shadow root's get the parent](https://dom.spec.whatwg.org/#ref-for-get-the-parent%E2%91%A6) is invoked on the shadow root, we go to the new logic:
   > 1. let _target_ be event’s path’s first struct’s invocation target;
   > 2. if _event_’s composed flag is set, or shadow root is not the root of _target_, return return shadow root’s host;
   > 3. otherwise, if _event_ has an invoker, and _event_'s invoker's root is a shadow-including ancestor of shadow root, return the result of retargeting _target_ against event's triggering element;
   > 4. otherwise, return null.
   
   so _target_ is `innerPopover`; shadow root _is_ the root of _target_; event has an invoker, `button`; `button`'s root (shadow root) _is not_ a shadow-including ancestor of shadow root (since it's non-inclusive ancestors only); so, we return null as the parent element.
13. 🆕 Back in event dispatch the path is still just [`innerPopover`, shadow root].
14. Event dispatch continues as normal with the given event path
15. 🆕 If [`composedPath()`](https://dom.spec.whatwg.org/#dom-event-composedpath) is called on _event_, it returns [`innerPopover`, shadow root].

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

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

Received on Tuesday, 15 April 2025 01:10:35 UTC