- From: Dan Clark <notifications@github.com>
- Date: Thu, 28 May 2026 08:45:17 -0700
- To: WICG/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <WICG/webcomponents/issues/1098/4565794715@github.com>
dandclark left a comment (WICG/webcomponents#1098) Thanks @smaug---- for taking a look at this, sorry for missing this comment till just now. A problem with `relatedTarget` is that for non-composed events (which are the ones that we're trying to address here), the event will still not be dispatched out of the shadow root even if we set its related target. This is because [shadow root's get the parent](https://dom.spec.whatwg.org/#ref-for-get-the-parent%E2%91%A6) algorithm doesn't check relatedTarget. > A [shadow root](https://dom.spec.whatwg.org/#concept-shadow-root)’s [get the parent](https://dom.spec.whatwg.org/#get-the-parent) algorithm, given an event, returns null if event’s [composed flag](https://dom.spec.whatwg.org/#composed-flag) is unset and [shadow root](https://dom.spec.whatwg.org/#concept-shadow-root) is the [root](https://dom.spec.whatwg.org/#concept-tree-root) of event’s [path](https://dom.spec.whatwg.org/#event-path)’s first struct’s [invocation target](https://dom.spec.whatwg.org/#event-path-invocation-target); otherwise [shadow root](https://dom.spec.whatwg.org/#concept-shadow-root)’s [host](https://dom.spec.whatwg.org/#concept-documentfragment-host). We have to make some change to [shadow root's get the parent](https://dom.spec.whatwg.org/#ref-for-get-the-parent%E2%91%A6) to allow the event's dispatch to escape to the markup of the source element. If we tried to do this by making [shadow root's get the parent](https://dom.spec.whatwg.org/#ref-for-get-the-parent%E2%91%A6) check the relatedTarget, then we'd be affecting behavior for the mouse/focus events that use relatedTarget, which we don't want. > If there are cases when source and retargeted original target can be then same, then perhaps tweaking when the event propagation [stops](https://dom.spec.whatwg.org/#:~:text=Otherwise%2C%20if%20parent%20is%20relatedTarget%2C%20then%20set%20parent%20to%20null%2E) could be enough - from that point onward event propagation could just work normally. Uncomposed events would stop at the next shadow boundary. But I'm not sure we need even that. An important property of @alice's proposal is that dispatch will skip intermediate shadows in the case where there are multiply-nested shadows. This is where the retargeting we're adding here comes into play. See @jakearchibald's example [here](https://github.com/WICG/webcomponents/issues/1098#issuecomment-2804289613). If we only make changes to where event propagation stops, then we'd be firing the event on every nested shadow between `source` and `target`, even if they don't have any relation to the event. -- Reply to this email directly or view it on GitHub: https://github.com/WICG/webcomponents/issues/1098#issuecomment-4565794715 You are receiving this because you are subscribed to this thread. Message ID: <WICG/webcomponents/issues/1098/4565794715@github.com>
Received on Thursday, 28 May 2026 15:45:21 UTC