Skip to content

Detach adopted attributes from their elements - #724

Open
andrewiggins wants to merge 4 commits into
adopt-inserted-subtreesfrom
adopt-attached-attributes
Open

andrewiggins wants to merge 4 commits into
adopt-inserted-subtreesfrom
adopt-attached-attributes

Conversation

@andrewiggins

Copy link
Copy Markdown
Contributor

Summary

Detach an attached Attr when passed to Document.adoptNode(), including same-document adoption.

  • Remove the exact attribute by identity through a shared internal NamedNodeMap removal helper.
  • Commit detachment and destination ownership before removal hooks or custom-element callbacks run.
  • Preserve reentrant reattachment and third-document adoption; notification errors leave ownership coherent.
  • Keep ordinary map removal behavior and generic subtree adoption unchanged.
  • Add focused regression tests and a patch changeset for @remote-dom/polyfill.

Stack and scope

Stacked on #682 (adopt-inserted-subtrees), which owns generic subtree adoption. This is the focused attached-Attr follow-up split from #693 and does not depend on indexed/named NamedNodeMap property access. Tests obtain attributes through getNamedItem() / getNamedItemNS().

Validation

  • Focused attached-Attr tests: 12 passed.
  • Existing subtree adoption tests: 13 passed.
  • Existing NamedNodeMap and custom-element reaction suites: 27 passed.
  • Full unit suite: 558 tests passed across 48 files.
  • pnpm type-check, pnpm lint, pnpm build, pnpm size, and git diff --check: passed.
  • Polyfill bundle: 11.22 kB against the existing 12 kB limit.
  • Playwright: 13 tests passed on an unchanged retry; the initial run had four iframe interaction timeouts.
  • Verified native Chrome detaches same-document attached attributes, exposes destination ownership to removal callbacks during cross-document adoption, and preserves a callback's third-document adoption. Also verified the built polyfill's callback ownership and reentrant transfer behavior.

No existing pinned WPT test was found that directly adopts an attached Attr, so this PR does not change WPT classifications. Related adoption WPTs remain blocked by unrelated APIs/behavior. Polyfill-specific hooks and exception propagation are covered by unit tests, not claimed as native-browser equivalents.

@andrewiggins
andrewiggins added this pull request to stack #716 September 17, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants