- From: Dan Fabulich <notifications@github.com>
- Date: Tue, 16 May 2023 10:35:47 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/831/1550093544@github.com>
Yes, the WebKit blog has a similar example of manipulating closed Declarative Shadow DOM from script. Their example also uses a custom element. https://webkit.org/blog/13851/declarative-shadow-dom/ ```html <some-component> <template shadowrootmode="closed">hello, world.</template> </some-component> ``` ```js customElements.define('some-component', class SomeComponent extends HTMLElement { #internals; constructor() { super(); this.#internals = this.attachInternals(); // This will log "hello, world." console.log(this.#internals.shadowRoot.textContent.trim()); } }); ``` It's true that you can't do this if the element is a `<div>`. But I think your mistake was to think that if you can't manipulate a `<div>`'s closed DSD, you simply can't "do" a `<div>` with closed DSD at all. Shadow DOM created with `attachShadow()` _requires_ you to manipulate it via script; if there were a design bug that prevented you from manipulating closed `attachShadow()` DOM in script, then the whole feature would be useless. But closed DSD is useful in its own right, even if you never manipulate it via script. The fact that the closed DSD can't be manipulated via script is a good thing; it's arguably the whole point of closed DSD, to _truly_ lock down a shadow root. Since `<div>` with closed DSD works great, and is useful, I can't see why anyone would want to remove the feature. For "parity"? Who benefits from removing this feature? -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/831#issuecomment-1550093544 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/831/1550093544@github.com>
Received on Tuesday, 16 May 2023 17:35:52 UTC