Re: [WICG/webcomponents] [scoped-registries] Describe interaction with declarative shadow DOM (#915)

@justinfagnani commented on this pull request.



> +
+Since these shadow roots are not created by a host calling `attachShadow()`, the host doesn't have a chance to pass in a scoped custom element registry. If a host is using a scoped registry, we need to force the declarative shadow root to not use the global registry and instead leave custom elements un-upgraded until the host can create and assign the correct registry.
+
+To do this we add a `shadowrootregistry` attribute, according to the [declarative shadow root explainer section on additional `attachShadow()` options](https://github.com/mfreed7/declarative-shadow-dom/blob/master/README.md#additional-arguments-for-attachshadow). This attribute causes the declarative shadow root to have no registry associated with it at all:
+
+```html
+<my-element>
+  <template shadowrootmode="open" shadowrootregistry="">
+    <some-scoped-element></some-scoped-element>
+  </template>
+</my-element>
+```
+
+The shadow root created by this HTML will have a `null` registry, and be in a "awaiting scoped registry" state that allows the registry to be set once after creation.
+
+To identify this "no registry, but awaiting one" state, ShadowRoot will have a `scopedRegistry` boolean property. `scopedRegistry` will set to `true` for all ShadowRoots with a scoped registry, or awaiting a scoped registry. Code can tell that ShadowRoot has an assignable `registry` property if `root.registry === null && root.scopedRegistry === true`.

I think that would be `shadowRoot.customElements` instead of `shadwoRoot.registry`?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/pull/915#discussion_r1175707222
You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/pull/915/review/1398677516@github.com>

Received on Monday, 24 April 2023 19:37:49 UTC