- From: Jan Miksovsky <notifications@github.com>
- Date: Tue, 08 Oct 2019 10:20:44 -0700
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/webcomponents/issues/842/539615845@github.com>
@justinfagnani Scoped registries will be great! But they solve a different problem, no? The focus here is that having to learn and think about registries — whether global or scoped — adds conceptual load. Scoped registries increase (rather than decrease) the knowledge and code required to instantiate an element:
```js
class MyElement extends HTMLElement {}
const myRegistry = new CustomElementRegistry(window.customElements);
myRegistry.define('my-element', MyElement);
const myElement = new MyElement();
```
[I'm not entirely sure the above would actually work. The examples at #716 show the association of a scoped registry with a shadow root. If that's absolutely required — e.g., to avoid name conflicts with those in the global registry — then even the verbose code above wouldn't be possible to instantiate elements at the document level.]
The main thing I'm trying to convey is that, over the past couple of years, I've come to realize that the number of situations in which I actually care about the tag name is small. In which the tag name is, at best, a side concern, it would be nicer to be able to just create the class and instantiate it.
Addressing this is clearly not essential — we can work around the problem. But looking at other libraries on the web today that export classes, I can usually instantiate those classes immediately; no other bookkeeping is required. I'm just observing that the need to register classes at all makes working with custom element classes more complex.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/842#issuecomment-539615845
Received on Tuesday, 8 October 2019 17:21:06 UTC