Re: [w3c/webcomponents] Expose shadowRoot on element internals (#871)

> Can we split the change for `attachInternals` to its own PR instead of tying it to the change to expose `shadowRoot`?

Definitely - done. There are now two:
 1. [Prevent attachInternals() use before custom element constructor](https://github.com/whatwg/html/pull/5909)
 2. [Add ElementInternals.shadowRoot](https://github.com/whatwg/html/pull/5912)


> I also wonder if there is a way to restrict `attachShadow` until the constructor is called. Right now, when you call `attachInternals` and get the shadow root, you don't know whether it's coming from the declarative shadow root or some shadow root other scripts have attached. The combination of upgrading and backwards compatibility makes this challenging. Because of upgrades, we wouldn't know whether a given element will allow shadow root or not. If backwards compatibility weren't an issue, we could make `attachShadow` fail until the constructor is called.
> 
> One possibility is to automatically fail an upgrade when non-declarative shadow root had been attached before the constructor has been called when internals is enabled. ...

One alternative suggestion might just be to add a flag for declarative shadow roots, so that the constructor can tell the difference? E.g. `shadowRoot.isDeclarative` or something?

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

Received on Monday, 14 September 2020 20:17:17 UTC