- From: Justin Fagnani <notifications@github.com>
- Date: Wed, 10 Aug 2022 13:53:32 -0700
- To: WICG/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <WICG/webcomponents/pull/965/review/1068910693@github.com>
@justinfagnani commented on this pull request. > @@ -60,6 +60,8 @@ registry.define('other-element', OtherElement); Definitions in this registry do not apply to the main document, and vice-versa. The registry must contain definitions for all elements used. +Note that, in the above example, `<other-element>` is defined in the scoped registry, not `<my-element>`. The registry applies to definitions _within_ the shadow root, not the element that the shadow root is attached to. I'm finding this wording a bit unclear.... especially "`<other-element>` is defined in the scoped registry, not `<my-element>`" and "not the element that the shadow root is attached to." > @@ -119,6 +121,23 @@ As a result, it must limit constructors by default to only looking up registrati This poses a limitation for authors trying to use the constructor to create new elements associated to scoped registries but not registered as global. More flexibility can be analyzed post MVP, for now, a user-land abstraction can help by keeping track of the constructor and its respective registry. +### Note on light DOM custom elements + +Custom elements that use light DOM (i.e. that don't call `this.attachShadow()`) may be scoped, but they must be scoped within a shadow root. For example: I think this is a bit confusing as there's no difference in defining elements in a scoped registry, regardless of whether they do or don't use shadow DOM. This seems to be blurring the language between what scope an element is defined in vs whether the element can have its own scope for its own definitions. > +### Note on light DOM custom elements + +Custom elements that use light DOM (i.e. that don't call `this.attachShadow()`) may be scoped, but they must be scoped within a shadow root. For example: + +```html +<body> + <shadow-element> + #shadow-root (registry=myCustomRegistry) + <light-element> + <div>Light DOM</div> + </light-element> + </shadow-element> +</body> +``` + +In the above example, `<light-element>` is scoped within the shadow root of its containing `<shadow-element>`, whereas `<shadow-element>` is defined at the global document level. I'm not sure I understand this. Declarative custom element definitions do not exist yet, and there's no such thing as a light-root. If `<light-element>` wants its own scope it'll have to programmatically create one and ensure that an elements it create use scoped instantiation APIs, which right now are only available on ShadowRoot, though we could conceivably also add them to CustomElementRegistry. -- Reply to this email directly or view it on GitHub: https://github.com/WICG/webcomponents/pull/965#pullrequestreview-1068910693 You are receiving this because you are subscribed to this thread. Message ID: <WICG/webcomponents/pull/965/review/1068910693@github.com>
Received on Wednesday, 10 August 2022 20:53:47 UTC