Re: [w3c/webcomponents] Is there a way to retrieve the localName from a custom element constructor? (#566)

One use case i'm currently finding for this is as follows.

When i try to call a constructor `new CustomElementCtro` the invocation could either fail because of the registry of an error unrelated to the registry that is rooted in the `constructor` function.

The framework has measures in place to handle thrown errors, so i want to avoid swallowing both of these, but it's hard to know where the error is from with the current `TypeError` object since between Chrome, FireFox and Safari only Safari mentions that it is related to the registry(albeit it might just be bad design on my part to try to sniff this info from the TypeError). 

However, what i am trying to do is branch only when the error is indeed related to the registry. 

This allows me to either 1. Display a specific error message or 2. Branch into generating and defining a unique name for the custom element at runtime. I'm sure it's still currently possible to archive this in author space, however the presence of this API would make it a easier to guarantee with either a `has` or `get` variant i.e.

```js
if (customElements.has(CustomElementCtro))
    branch1
else
    branch2
```

-- 
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/566#issuecomment-372135404

Received on Sunday, 11 March 2018 18:04:32 UTC