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

I don't think prohibiting constructors from being used in multiple registries is a good idea. It means that we'll need trivial subclasses for each registry (and there could be 100s of registries, resulting in 1000s of new subclasses), and that it would be strictly _dangerous_ to expose a custom element class because anyone who registers it without subclassing would cause an error for other consumers.

We talked this part through in several meetings in the context of how `new MyElement()` should work, and considered a variant where CustomElements.define() automatically subclasses and returns the subclass, but rejected that in favor of `new MyElement()` only working for the global registry and coming back to how to make scoped constructors work later.

Thus the line in the example that's causing a problem should not actually be a problem, I think:

```ts
  createdByNestedCall = new ReentryByDirectCall;
```

because this can only create an instance in the global registry, and because this call is after `super()`, the tag applied to the constructor should have been cleared (it should be cleared before the return from the HTMLElement constructor).

Constructor before `super()` could be ambiguous, but those are _already_ dangerous due to the constructor call trick used during upgrades. I think it's fine to have the same restriction for scoped registries.

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

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

Received on Tuesday, 7 March 2023 03:07:54 UTC