justinfagnani / scoped-custom-elements

22 stars 1 forks source link

Add attribute to <template shadowroot> to disable upgrades #6

Open justinfagnani opened 4 years ago

justinfagnani commented 4 years ago

In order to make scoped custom element registries and declarative shadow DOM work together we need a way to defer upgrading of elements in some shadow roots until their custom element registry has been set.

An attribute can tell the browser to either not upgrade the contained elements, or possibly to create an empty registry which would have the same effect.

<my-element>
  <template shadowroot scoped-custom-elements>
</my-element>

Then when the definition of my-element loads, it can set the registry, in conjunction with #3, to trigger upgrades.

This should be specified here, to make this proposal layer on top of declarative shadow DOM.

cc @mfreed7

caridy commented 4 years ago

This matches my mental model as well. Just like shadowroot attribute triggers the creation of a shadowRoot instance, the scope-custom-elements does the same, it creates a brand new (therefore, an empty registry that can be populated, or replaced once the component takes over).

Btw, we should bikeshed on the name of the scope-custom-elements attribute :), maybe just scoped.

justinfagnani commented 4 years ago

I worry that scoped is too general, since many things could be scoped and it might be read to apply to styling or something else.

And before the name even, I'd want to check that a boolean attribute is the way to go here, or whether there is some kind of enum we'd want to use. ie, if this attribute applies recursively, as would be expected from the registry lookup mechanism, a nested shadow root might want a way to opt out and use the global registry.

LarsDenBakker commented 4 years ago

I agree that scoped is too general. scoped-custom-elements should be fine.

leobalter commented 4 years ago

I'm more neutral to this change, I see pros and cons either way. In this manner I'd rather stick with the less conflicting name. So far, scoped-custom-elements should be fine.