Re: [w3c/webcomponents] Expose shadowRoot on element internals (#871)

> > Is there any problem with @rniwa's suggestion here?
> 
> I would be interested in seeing a specific proposed change, i.e. what algorithm steps to modify.

The change is very simple. We'd add a new step immediately below [step 1 of attachInternals](https://html.spec.whatwg.org/multipage/custom-elements.html#dom-attachinternals as follows:
2. If *element*'s [custom element state](https://dom.spec.whatwg.org/#concept-element-custom-element-state) is not "`custom`", throw "[`NotSupportedError`](https://heycam.github.io/webidl/#notsupportederror)" [`DOMException`](https://heycam.github.io/webidl/#dfn-DOMException).

> As suggested I believe it is a no-op, as a custom element's state becomes "custom" at the same observable time as the definition becomes present. But, I might be missing something, so a specific spec PR/tests would be helpful.

With the above change, the following test should pass:

```js
const someElement = document.createElement('some-element');

customElements.define('some-element', class extends HTMLElement {
  constructor() {
    super().attachInternals();
  }
});

assert_throws('NotSupportedError', () => someElement.attachInternals());
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/871#issuecomment-677959537

Received on Thursday, 20 August 2020 23:44:01 UTC