Re: [WICG/webcomponents] [scoped-registries] Interaction with HTML element's overridden constructor steps (Issue #969)

> No. It just means that you can't recursively call your own constructor before `super()` - which is already a restriction due to how upgrades work.

> This isn't a thing in the current proposal. Calling constructors is only supported for the global registry

It comes back to what I was saying, unless you are sure your component will be exposed globally, using constructors is not safe anymore.

```js
// This lib exposes 2 public components, but does not know if there are going to be defined 
// globally or scoped, nor the tag used. The only expectation is that they are going to be 
// defined somewhere accessible.
class A extends HTMLElement {}
class B extends HTMLElement {
 connectedCallback() {
     this.appendChild(new A());
  }
}
export { A, B };
```

Component `A` works globally or scoped, `B` will work globally but fails when scoped.

Wouldn't it be a good practice for libraries not to assume their component is globally defined, nor the actual tag it is defined under?

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

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

Received on Tuesday, 7 March 2023 17:35:47 UTC