- From: Joe Pea <notifications@github.com>
- Date: Thu, 17 Apr 2025 23:47:15 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/1365/2814690269@github.com>
trusktr left a comment (whatwg/dom#1365) > You are combining too many things in a single issue. It's no longer clear to me what this issue is about. There is a single issue in this thread, which is the fact that a Custom Element constructor can see the following unexpected state and incorrect logic will happen: ```js console.log(internals.shadowRoot) // null console.log(this.shadowRoot) // ShadowRoot ``` The problem code: ```js if (!internals.shadowRoot) this.attachShadow(...) // THROWS. ``` This is a problem because a CE author cannot reliably detect Declarative Shadow DOM in certain cases. It is a considerable problem because: - It requires users to ensure that their custom element definitions run *after* DOM parsing (for example, after `DOMContentLoaded`) - this is problematic for custom elements that are designed to be instantiated during streaming (imagine a long page with lots of HTML before the bottom is reached), - if the author of these elements wants to support Declarative Shadow DOM to be ready for SSR, then they can no longer instantiate elements during streaming, but must instead do so after (a potentially long) HTML payload is finished being received. - Following the previous requirement causes various issues, such as FOUC due to definitions loading later instead up front, or bugs due to changes in the order of element upgrade (conflicting with the best practice people some people have expressed of loading element definitions at the top of the HTML payload, not the bottom). - And I was also mentioning that this makes it difficult to spec new features (for example Declarative Custom Elements which ideally should define themselves as soon as possible, without the timing causing `ElementInternals` to in a broken state) -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/1365#issuecomment-2814690269 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/1365/2814690269@github.com>
Received on Friday, 18 April 2025 06:47:19 UTC