Skip to content

Scoped registry review fixes - #670

Open
sorvell wants to merge 11 commits into
scoped-registry-cross-realmfrom
scoped-registry-review-fixes
Open

sorvell wants to merge 11 commits into
scoped-registry-cross-realmfrom
scoped-registry-review-fixes

Conversation

@sorvell

@sorvell sorvell commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #668 and #669. Base: scoped-registry-cross-realm (#669).

The result of several review passes over #668, with these goals: correct, robust, readable, simple to maintain, and small. The changes fall into two kinds.

Simpler, easier-to-maintain code

  • Each rule lives in one place:
    • getRegistry, split into small helpers for the three ways a node gets its registry;
    • withAdoption for every adopting insertion;
    • one tree walk (forEachInTree);
    • one parsing wrapper (replaceChildrenByParsing).
  • Dead code is gone: unused maps, fields and parameters, no-op guards, redundant checks.
  • Comments are corrected or rewritten where stale or unclear, and declarations sit next to their first use.

Correct, robust behaviour
Where the polyfill differed from native, it now follows the spec:

  • Which registry an element has: when it's created (including with new X()), cloned, adopted or moved, including when an insertion throws partway.
  • When it's customized: at most once. A failed upgrade is final and clears the element's definition, as natively.
  • What it gets: attribute callbacks in attribute order; form callbacks only for form-associated elements, including on upgrade; attachInternals only for custom elements; argument checking as in WebIDL.
  • Missing interception points are added, e.g. Document.append, textContent and setHTML.

Soundness

  • No API changes.
  • Every behaviour fix has a test that failed before it. The full suite passes in Chromium, Firefox and WebKit, with and without force.
  • WPT: 3 more tests pass in every browser, so each known-failure list shrinks by 3.
  • Size: +0.5 KB minified, +0.3 KB gzipped.

Steve Orvell added 10 commits October 23, 2026 07:03
…ception points, attribute callback order, one tree walk
…try, adoption rollback, shared parsing wrapper
…associated stand-ins, waiting elements and adoption, record parentless nodes before moves
…paired fragment copies, comments

Internal code calls getRegistry rather than the public getter. A failed upgrade removes the element's definition, as natively, so isFailed checks go and a failed element can attach a shadow root. A fragment or document copy that can't be paired keeps its elements' positional registries instead of null. Removes the adoptedCallback registry change (patched APIs already do it), an unused interface augmentation and other small redundancies. Fixes stale comments.
…ows, adoptRegistries uses forEachInTree, clearer names and comments
@sorvell
sorvell requested a review from bicknellr as a code owner October 23, 2026 14:42
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.

1 participant