- From: Joe Pea <notifications@github.com>
- Date: Sun, 06 Apr 2025 11:48:12 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/1365/2781558035@github.com>
trusktr left a comment (whatwg/dom#1365) Why is a ShadowRoot `available to element internals` state even needed? It is not possible to get `ElementInternals` before upgrade right? For example, calling `attachInternals` like this throws: ```html <script type=module> customElements.define( 'x-x', class extends HTMLElement { } ) const t = document.createElement('template') t.innerHTML = `<x-x></x-x>` const el = t.content.children[0] el.attachShadow({mode: 'open'}) const internals = el.attachInternals() console.log(internals.shadowRoot, el.shadowRoot) </script> ``` [CodePen demo](https://codepen.io/trusktr/pen/ZYEZeeK?editors=1000) Based on the that, the only place that a custom element author can ever start to use `ElementInternals` is (should be) in the custom element constructor. And based on that, there seems to be no reason to have a ShadowRoot `available to element internals` state, and `ElementInternals.shadowRoot` should just show any existing root to the custom element author anyway (with or without that state). Unless I missed something, it seems that - step 4 from the `shadowRoot` getter steps can be deleted: https://html.spec.whatwg.org/multipage/custom-elements.html#dom-elementinternals-shadowroot - `available to element internals` can be deleted from the index: https://dom.spec.whatwg.org/#index-defined-here - The definition of `available to element internals` can be deleted from the ShadowRoot interface: https://dom.spec.whatwg.org/#interface-shadowroot - and step 7 from `attach a shadow root` can be deleted: https://dom.spec.whatwg.org/#concept-attach-a-shadow-root Are `ElementInternals` somehow available before an element's upgrade in some other way than in my last example? If so, it may not be worth fixing that, however fixing that would be better than the `available to element internals` problem we have here. -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/1365#issuecomment-2781558035 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/1365/2781558035@github.com>
Received on Sunday, 6 April 2025 18:48:16 UTC