Re: [whatwg/dom] feature: `element.getShadow(opts)` (Issue #1046)

You could just do the following right? ([See here](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/shadowRoot))

```js
const shadowRoot = this.#internals.shadowRoot ?? this.attachShadow({ ...opts });
```

Whether it is worth abstracting this into a new method I'm not sure. Although I would ask are empty shadow roots really so expensive that you can't just attach them unconditionally in the constructor? i.e.:

```js
#internals = this.attachInternals();

constructor() {
    this.#attachShadow({ ...opts });
}

connectedCallback() {
    this.#internals.shadowRoot.innerHTML = ``;
}
```

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

Message ID: <whatwg/dom/issues/1046/1025323839@github.com>

Received on Monday, 31 January 2022 02:31:58 UTC