- From: Alice <notifications@github.com>
- Date: Tue, 15 Apr 2025 20:41:48 -0700
- To: WICG/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <WICG/webcomponents/issues/1098/2808147407@github.com>
alice left a comment (WICG/webcomponents#1098)
#### Testing the new new logic for slotted content in deeper shadow DOM
Maybe I should just write some code for this instead, but just one more.
```html
<template shadowrootmode="open">
<!-- shadow0 -->
<x-form id="xForm">
<template shadowrootmode="open" shadowrootreferencetarget="thing">
<!-- shadow1 -->
<inner-thing id="thing">
<template shadowrootmode="open" shadowrootreferencetarget="form">
<!-- shadow2 -->
<slot>
<!-- form gets slotted in here -->
</slot>
</template>
<form id="form"></form>
</inner-thing>
</template>
</x-form>
<label>Name: <input id="input" form="xForm"></label>
</template>
```
Steps 1-6 are the same as above.
7. When [a node's get the parent](https://dom.spec.whatwg.org/#ref-for-get-the-parent%E2%91%A4) is invoked on `form`, it returns `slot`.
8. When [a node's get the parent](https://dom.spec.whatwg.org/#ref-for-get-the-parent%E2%91%A4) is invoked on `slot`, it returns `shadow2`.
9. 🆕 When [a shadow root's get the parent](https://dom.spec.whatwg.org/#ref-for-get-the-parent%E2%91%A6) is invoked on `shadow2`, we go to the (_new_) new logic:
> 1. let target be event’s path’s first struct’s invocation target;
> 2. if event’s composed flag is set, return shadow root’s host;
> 3. if shadow root is not the root of target, and event does not have a source or shadow root is not the root of event's source, return shadow root's host;
> 4. if event has a source, and event's source's root is a shadow-including ancestor of shadow root, return the result of retargeting target against event's triggering element;
> 5. otherwise, return null.
1. _target_ is `form`;
2. the composed flag is _not_ set
3. `shadow2` is _not_ the root of `form` (`true`); event has an `source`, `input`, and `shadow2` is _not_ the root of `input` (`true`), so `true && true` and we return `thing`.
10. When a node's get the parent](https://dom.spec.whatwg.org/#ref-for-get-the-parent%E2%91%A4) is invoked on `thing`, it returns `shadow1` as normal.
11. 🆕 When [a shadow root's get the parent](https://dom.spec.whatwg.org/#ref-for-get-the-parent%E2%91%A6) is invoked on `shadow1`, we go to the (_new_) new logic:
> 1. let target be event’s path’s first struct’s invocation target;
> 2. if event’s composed flag is set, return shadow root’s host;
> 3. if shadow root is not the root of target, and event does not have a source or shadow root is not the root of event's source, return shadow root's host;
> 4. if event has a source, and event's source's root is a shadow-including ancestor of shadow root, return the result of retargeting target against event's triggering element;
> 5. otherwise, return null.
1. _target_ is `form`;
2. the composed flag is _not_ set
3. `shadow1` _is_ the root of `form` (`false`); event has an `source`, `input`, and `shadow1` is _not_ the root of `input` (`true`), so `false && true` and we don't return shadow root's host but go to step (4)
4. `input`'s root (`shadow0`) _is_ a shadow-including exclusive ancestor of `shadow1`; so, we return the result of retargeting `form` against `input` yielding `xForm`.
10. (same as step 9 above.)
11. (same as step 10 above.)
12. 🆕 Back in event dispatch where the path would previously have just been [`form`, `slot`, `shadow2`, `thing`, `shadow1`], it now goes [`form`, `slot`, `shadow2`, `thing`, `shadow1`, `xForm`, `shadow0`].
--
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/1098#issuecomment-2808147407
You are receiving this because you are subscribed to this thread.
Message ID: <WICG/webcomponents/issues/1098/2808147407@github.com>
Received on Wednesday, 16 April 2025 03:41:52 UTC