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

@mfreed7 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`.

Oh! Thanks, I missed that. I agree with renaming `shadowRoot.registry` to `shadowRoot.customElements`, which is exactly what you both wrote, but I failed to read correctly.

The DOM does use `is` sometimes, e.g. `isConnected`, `isTrusted`, `isMap`, `isContentEditable`, etc. The `has` prefix (which seems like what we'd want here) is also used, though less so. For example, `hasBeenActive`. If `has` is acceptable, I'd definitely lobby for renaming `shadowRoot.scopedRegistry` to `shadowRoot.hasScopedRegistry`.

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

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

Received on Monday, 24 April 2023 20:29:24 UTC