- From: Nicolas Gilbert <notifications@github.com>
- Date: Mon, 06 Mar 2023 16:51:29 -0800
- To: WICG/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <WICG/webcomponents/issues/969/1457292619@github.com>
I may be a question of preference, but I find that definition-time error would be caught earlier and thus be clearer than component run-time. And as you've pointed, it would would also avoid a breaking change with the current standard that allows calling a constructor from itself. But most of all, I think it would be a shame that elements registered on custom registries wouldn't be able to be created using constructors at all. I personally often use this kind of dependency injection pattern: ```js class AbstractConfirmBar extends HTMLElement { constructor({ SubmitButton, CancelButton }) { super(): this.SubmitButton = SubmitButton; this.CancelButton = CancelButton; } connectedCallback() { this.appendChild(new this.SubmitButton()); this.appendChild(new this.CancelButton()); } } ``` Such a component would work as expect with global-registered components, but not with custom-registered components. There are other ways to achieve the same result, but in the end the real problem is the inconsistency. Some patterns would simply be forbidden when a component becomes registered on a custom registry, even if it worked perfectly fine until then. -- Reply to this email directly or view it on GitHub: https://github.com/WICG/webcomponents/issues/969#issuecomment-1457292619 You are receiving this because you are subscribed to this thread. Message ID: <WICG/webcomponents/issues/969/1457292619@github.com>
Received on Tuesday, 7 March 2023 00:51:41 UTC