Re: [whatwg/dom] [ElementInternals] `ElementInternals.shadowRoot` is `null` but `this.shadowRoot` is not (its a `ShadowRoot`) (Issue #1365)

trusktr left a comment (whatwg/dom#1365)

It was introduced to prevent someone defining an undefined custom element (element with dash in the name) and getting the `ShadowRoot`. That's not worth it though.

This issue causes another problem that is not so obvious: Custom Elements defined with synchronous script tags *before* parsing cannot use DSD, because this issue breaks CE code (constructors will see `null` instead of DSD `ShadowRoot`).

In order to use DSD, custom element definitions have to happen *after* parsing. This is a huge problem. I know people who have already sworn that defining elements up front is the best way to go for various reasons (name: avoid upgrade ordering issues, avoid flash of unstyled content).

And now, with this `ElementInternals.shadowRoot` problem, all of those people have to defer their script loading to use DSD, introducing upgrade order issues, and flashes of unstyled content.

I believe ElementInternals needs to be in sync with the state of the element's ShadowRoot existence for the sake of developer sanity.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1365#issuecomment-2787139119
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/1365/2787139119@github.com>

Received on Tuesday, 8 April 2025 17:13:42 UTC