Skip to content

[scoped-custom-element-registry] Redesign the polyfill - #668

Open
sorvell wants to merge 12 commits into
masterfrom
scoped-registry-redesign
Open

sorvell wants to merge 12 commits into
masterfrom
scoped-registry-redesign

Conversation

@sorvell

@sorvell sorvell commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Supersedes #604. Updates the polyfill to the current registry model, including null registries, initialize(), declarative shadow roots, and registry preservation across moves, cloning, and adoption. Supports both attribute spellings involved in whatwg/html#12000.

The native stand-in approach remains. Construction now queues elements until their registries are recorded, then invokes their user constructors before the patched DOM call returns. Main-parser elements wait until the document becomes interactive. Registry bookkeeping is independent of native scoped-registry support.

For review:

  • Skim the README for supported behavior and documented limitations.
  • Read the implementation as a complete file, starting with “How it works.” Focus on registry assignment, nested upgrade queues, and clone pairing.
  • Review the tests: common-registry-tests.js covers shared registry behavior; behavior.test.js covers DOM operations and lifecycle edge cases; parsing.test.html(.js) covers parser timing.
  • Review the separate tooling commit: Node/Playwright updates, removal of Sauce Labs, and forced-polyfill Chromium coverage.

The old ShadowRoot.createElement, createElementNS, and importNode APIs are replaced by document APIs with an explicit customElementRegistry option.

npm test builds and runs Chromium, Firefox, WebKit, and forced-polyfill Chromium. Tests marked itWithPolyfill cover polyfill-specific behavior or documented native discrepancies.

@google-cla

google-cla Bot commented Oct 1, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@sorvell
sorvell force-pushed the scoped-registry-redesign branch from 7b18f61 to 2162b48 Compare October 1, 2026 13:34
Steve Orvell added 4 commits October 1, 2026 06:42
…orced-polyfill Chromium run

- tests.yml: Node 24.5, actions v4, install Playwright browsers, drop the
  Saucelabs job
- scoped-custom-element-registry: test:forced runs the tests in Chromium with
  the polyfill forced (FORCE_POLYFILL), and npm test depends on it
- test/wtr.firefox.config.js: run the tests locally in a Firefox-engine
  browser without native support
A rewrite. Start with the "How it works" overview at the top of
src/scoped-custom-element-registry.ts, then read the file rather than the
line diff.
behavior.test.js and parsing.test.html(.js) are new; tests of polyfill-only
behavior, and of spec behavior Chromium gets wrong, use itWithPolyfill so the
suite also runs against native implementations.
@sorvell
sorvell force-pushed the scoped-registry-redesign branch from 2162b48 to 698b7c2 Compare October 1, 2026 13:43
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