Re: [w3c/webcomponents] Why can't the registry enumerate the custom elements? (#775)

Invisibility-by-default is a user-hostile paradigm.  I could ask, what problem are we trying to prevent by hiding them?  After all, in JavaScript it takes more effort to hide something than to expose it.  As this is a design decision, it should be stated somewhere.

For example, you can make an argument for why `EventTarget` listeners are not enumerable.  If a third party could find out what listeners are registered, then it could unregister someone else's listeners.  I would certainly accept that this is undesirable, (although note that [in Node `EventerEmitter` listeners *are* exposed](https://nodejs.org/api/events.html#events_emitter_listeners_eventname).).

`EventTarget` offers protection against that since the functions are registered by reference, and subscribers can hide the function reference (i.e. not leak it), even while retaining it in a context where they can later unsubscribe.

By-reference protection doesn't apply to `CustomElementRegistry`, since the elements are keyed by name.  But it offers even stronger protections:

- no one can unregister an element
- no one can re-register a certain tag
- no one can re-register a certain *component*

With those protections, I fail to see what harm could arise from making components discoverable.

Again, I see the burden-of-proof the other way around.  But I will say a few words about my use case.  The web is our best shot at a worldwide, user-empowering, dynamic computing environment.  We have the tools to create a platform where models are fully portable, decomposable, visible, and self-documenting at runtime.  In such an environment, users can build new models from the components that are available.  Built-in elements are not enumerable as such, but they are well-known.  Since the user might not know all of the *new* components that have been loaded in a given context, enumeration of the registry would be the most direct way to make their availability known.

-- 
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/775#issuecomment-443214618

Received on Friday, 30 November 2018 14:11:49 UTC