[WICG/webcomponents] [element-internals] (Issue #962)

How does a sub class get the internals? This isn't working:

```js
class Base extends HTMLElement {
  #_
  
  constructor() {
    super()
    this.#_ = this.attachInternals()
  }
}

class MyEl extends Base {
  #_
  
  constructor() {
    super()
    this.#_ = this.attachInternals() // subclass also wants it, but this causes runtime error
  }
}

customElements.define('my-el', MyEl)

document.body.append(document.createElement('my-el')) // ERROR
```

The error in Chrome is:

```
Uncaught DOMException: Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.
```

The Tc39 ES group thought `protected` was not a worthy thing to give us. So now what do we do? Have to implement some sort of intricate dance for each class in the hierarchy?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/962
You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/issues/962@github.com>

Received on Tuesday, 26 July 2022 06:00:56 UTC