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

Thanks for the clarification. 

If I understand correctly, this means that any component coming from code you don't control (e.g. 3rd party library) will need to be adjusted to avoid using constructors? That a component that currently works on the global registry may throw an error if moved to a custom registry? That the error may happen deeply in the component during a rare and hard to test flow, thus causing bugs that could even reach production? This does sound *dangerous*.

I can see that reusing the same constructor could cause some exceptions, but there would all be definition-time and likely to be caught early. Knowing that custom registries are not yet available, it is unlikely that they will spread so far and wide that suddenly libraries you don't control cross-register the same constructor. The worst case scenario I can see is that a developer tries to redefine a constructor, see that it throws, that then subclasses it. 

For the number of sub-classing required, I wonder if we don't overestimate the problem. I may be mistaken, but the use case for scoped components wouldn't be primarily for privately defined sub-components? I would expect libraries to discourage the reuse of those components outside the library itself. In this scenario, no subclassing would even be required.

The most annoying scenario I see would be if lib A and B both use components from lib C. To avoid collisions, both A and B would need a mechanism to use components from C without exposing them to globally. 

Could registries extend other registries? In the previous example, instead of having both A and B having to redefine every components from C, it would be much simpler to define which registries you extend.

```js
const myRegistry = new CustomElementRegistry({ extends: [registryC, registryD] });
```

Where element lookup happens in order, from the current registry up the extended registries, in order. I would be easy for libraries to expose a registry with every components already registered.

Was something like that considered? Maybe you could help me understand other scenarios for re-registering the same constructor multiple times?

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

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

Received on Tuesday, 7 March 2023 13:03:08 UTC