Re: [whatwg/dom] Add reference target to shadow root (PR #1353)

annevk left a comment (whatwg/dom#1353)

<details>
<summary>AI feedback</summary>

Reviewed at 3c80a69. `make remote` builds cleanly with `die-on=warning`, and every DOM anchor that whatwg/html#10995 links to exists. The IDL, *attach a shadow root*, *clone a node*, and `attachShadow()` changes are consistent with each other and with Chromium.

I rebased this onto main as a single commit (2963838). The only conflict was the last step of *fire an event*, which main changed in 94f3fee. On top of that I pushed 5cd16ec with editorial fixes: *relatedTarget* is now typed as a potential event target to match its null default, two paragraphs are rewrapped, and the note on how other specifications use an event's relatedTarget now also covers limiting propagation.

I also refreshed web-platform-tests/wpt#51213 so it moves all current tests out of `tentative/`, keeping coverage for features that aren't standardized in `.tentative` files. I also added tests for cloning and for `attachShadow()` on a host with a declarative shadow root.

**Suggestions**

- HTML needs to reset form owners when a shadow root's [reference target changes](https://github.com/dandclark/dom/blob/5cd16ecdaee2be3a97f486e332f94b9f5f747bfb/dom.bs#L6847). Since whatwg/html@985d4435e, HTML's form-owner updates go through DOM hooks (insertion, removing, moving, and attribute change steps). There is no equivalent hook for this setter, so whatwg/html#10995 currently has to say "when the reference target changes" in prose. Consider giving the setter a hook other specifications can define steps for.
- Consider making [*dispatch*](https://github.com/dandclark/dom/blob/5cd16ecdaee2be3a97f486e332f94b9f5f747bfb/dom.bs#L1378)'s optional parameters named, as was done for *fire an event*. IndexedDB has three calls of the form "[=Dispatch=] |event| at |target| with |legacyOutputDidListenersThrowFlag|". Now that an optional `EventTarget` comes first, those calls read as passing a boolean as *legacyTargetOverride*. An IndexedDB follow-up could then link the named argument.
- The commit message at the top of the PR description only covers `ShadowRoot.referenceTarget`. Please also mention that *fire an event* gains a *relatedTarget* parameter, that the legacy target override flag became a *legacyTargetOverride* `EventTarget` parameter (so HTML now passes the `Document` itself), and that *clone a node* copies the reference target. Linking WICG/webcomponents#1086 and #1098 would also help.

</details>


-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/pull/1353#issuecomment-6858054706
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/pull/1353/c6858054706@github.com>

Received on Friday, 13 November 2026 15:56:51 UTC