{"action":"created","issue":{"url":"https://api.github.com/repos/w3c/webcomponents/issues/445","repository_url":"https://api.github.com/repos/w3c/webcomponents","labels_url":"https://api.github.com/repos/w3c/webcomponents/issues/445/labels{/name}","comments_url":"https://api.github.com/repos/w3c/webcomponents/issues/445/comments","events_url":"https://api.github.com/repos/w3c/webcomponents/issues/445/events","html_url":"https://github.com/w3c/webcomponents/issues/445","id":141424854,"number":445,"title":"Permit retrieval of registered classes from window.customElements","user":{"login":"JanMiksovsky","id":86139,"avatar_url":"https://avatars.githubusercontent.com/u/86139?v=3","gravatar_id":"","url":"https://api.github.com/users/JanMiksovsky","html_url":"https://github.com/JanMiksovsky","followers_url":"https://api.github.com/users/JanMiksovsky/followers","following_url":"https://api.github.com/users/JanMiksovsky/following{/other_user}","gists_url":"https://api.github.com/users/JanMiksovsky/gists{/gist_id}","starred_url":"https://api.github.com/users/JanMiksovsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JanMiksovsky/subscriptions","organizations_url":"https://api.github.com/users/JanMiksovsky/orgs","repos_url":"https://api.github.com/users/JanMiksovsky/repos","events_url":"https://api.github.com/users/JanMiksovsky/events{/privacy}","received_events_url":"https://api.github.com/users/JanMiksovsky/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-03-16T22:48:12Z","updated_at":"2016-03-21T09:37:18Z","closed_at":null,"body":"Following up on issue #431, I'd like to propose that window.customElements allow a dev to retrieve information about the custom elements which have been registered. It sounds like @domenic was supportive of this idea, so as a strawman, I propose adding the following:\r\n\r\n* `window.customElements.get(name)`. Returns the class which was previously registered with `define(name)`, or `undefined` if no element has yet been registered with that name.\r\n* `window.customElements[@@iterator]()`. This returns a new `Iterator` object that enumerates the `[name, class]` pairs registered. I don't particularly care in what order the entries are returned. For consistency with `Map.prototype[@@iterator]()`, it would be nice to return these in the order in which they were defined.\r\n\r\nThis, at least would meet the needs I've encountered, chiefly being able to: 1) easily verify that a particular custom element has in fact been registered, 2) conditionally define an element if it hasn't already been registered. E.g.:\r\n\r\n    if (!window.customElements.get('my-element')) {\r\n      window.customElements.define('my-element', MyElement);\r\n    }\r\n"},"comment":{"url":"https://api.github.com/repos/w3c/webcomponents/issues/comments/199193027","html_url":"https://github.com/w3c/webcomponents/issues/445#issuecomment-199193027","issue_url":"https://api.github.com/repos/w3c/webcomponents/issues/445","id":199193027,"user":{"login":"rianby64","id":25993,"avatar_url":"https://avatars.githubusercontent.com/u/25993?v=3","gravatar_id":"","url":"https://api.github.com/users/rianby64","html_url":"https://github.com/rianby64","followers_url":"https://api.github.com/users/rianby64/followers","following_url":"https://api.github.com/users/rianby64/following{/other_user}","gists_url":"https://api.github.com/users/rianby64/gists{/gist_id}","starred_url":"https://api.github.com/users/rianby64/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rianby64/subscriptions","organizations_url":"https://api.github.com/users/rianby64/orgs","repos_url":"https://api.github.com/users/rianby64/repos","events_url":"https://api.github.com/users/rianby64/events{/privacy}","received_events_url":"https://api.github.com/users/rianby64/received_events","type":"User","site_admin":false},"created_at":"2016-03-21T09:37:18Z","updated_at":"2016-03-21T09:37:18Z","body":"@annevk Let's not considering HTML imports, but let's consider what @JanMiksovsky proposed: window.customElements[@@iterator]()\r\nWhat about if manipulate the defined custom elements via _window.customElements.definitions_?\r\nI think that the existing structure for _Element.attributes_ fits good to _window.customElements.definitions_. Here we've the possibility to define functions like hasDefinition(), getDefinition() and so on."}}