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

> > In that scenario (non-upgrading case), you'd have to wait until all the children had been parsed for hydration.
> 
> With the current declarative SR proposal, this is fine, as the entire shadow root is created when all the shadow children are parsed.

No, it's not fine because the constructor of a custom element is always called before its children are parsed or created so in sync/non-upgrade construction case, the constructor will always run and then it can attach a non-declarative shadow root.

> If we found an acceptable way to do streaming, this would be an issue to tackle too.
> 
> Edit: I suppose the constructor could be called before the declarative shadow root is created at all.

This is not *could*. It's guaranteed to happen in that order.

> This would be a great time to add the `childrenParsed` or whatever callback. That's a problem that custom element authors have been hitting for a while now.

That doesn't necessarily solve the problem fully because then the custom element has to delay attaching a shadow root until that happens in the case there is a declarative shadow root, in which case, someone else can attach a shadow root, or worse yet, anyone can access to template's content and have reference to those nodes.

-- 
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-604750845

Received on Friday, 27 March 2020 00:16:08 UTC