Re: [WICG/webcomponents] Scoped Custom Element Registries (#716)

If we get rid of inheritance & scope, the proposal simplifies to the following. In my view, this is a lot more approachable & tenable proposal.

## API Changes

### `CustomElementRegistry`

  * `CustomElementRegistry()`
    `CustomElementRegistry` is constructable.

    New definitions added to a registry are not visible in the global registry.

### `ShadowRoot`

`ShadowRoot`s are already the scoping boundary for DOM and CSS, so it's natural to be the scope for custom elements. `ShadowRoot` needs a `CustomElementRegistry` and the DOM creation APIs that current exist on document.

  * `customElements: CustomElementRegistry`

    The `CustomElementRegistry` the `ShadowRoot` uses, set on `attachShadowRoot()`.
  * `createElement()`, `createElementNS()`
    These methods create new elements using the `CustomElementRegistry` of the `ShadowRoot`.
  * `importNode()`
    Imports a node into the document that owns the `ShadowRoot`, using the `CustomElementRegistry` of the `ShadowRoot`.

    This enables cloning a template into multiple scopes to use different custom element definitions.

### `Element`

New properties:
  * `Element.prototype.attachShadow(init: ShadowRootInit)`

    `ShadowRootInit` adds a new property, `customElements`, in its options argument which is a `CustomElementRegistry`.


-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/716#issuecomment-1188441389
You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/issues/716/1188441389@github.com>

Received on Monday, 18 July 2022 23:40:54 UTC