- From: Joshua Peek <josh@joshpeek.com>
- Date: Fri, 17 Oct 2014 13:34:06 -0700
- To: Dominic Cooney <dominicc@google.com>
- Cc: WebApps WG <public-webapps@w3.org>
Ah, interesting. If custom element interfaces are treated differently, it seems like this may negatively affect the "HTML as Custom Elements" work (https://github.com/dglazkov/html-as-custom-elements). Type extensions may or may not work depending on the element being truly native or not. On Thu, Oct 16, 2014 at 7:44 PM, Dominic Cooney <dominicc@google.com> wrote: > Hi Joshua, > > I implemented Custom Elements in Chrome. > > In the definition construction algorithm, step 8.2, it says: > > "If BASE does not exist or is an interface for a custom element, set ERROR > to InvalidName and stop." > > In this case, BASE is the x-button and it is an interface for a Custom > Element. I think this is the case you're hitting. I think Chrome roughly > matches the spec in this case. > > It's another question whether the spec could be changed to allow this. As an > implementer, I would need to know if/what order each of the callbacks for > x-button and x-submit-button were called in when something happened to an > x-submit-button. There are also interesting cases like what happens if the > x-submit-button is registered before the x-button, and whether other things > are possible like type extensions that extend other type extensions. > > In short, step 8.2 avoids a lot of potential complexity by limiting what you > can do with Custom Elements in this specific way. > > Dominic > > > On Fri, Oct 17, 2014 at 7:36 AM, Joshua Peek <josh@joshpeek.com> wrote: >> >> Is it legal to register a type extension on top of an existing custom tag? >> >> <x-button is="x-submit-button"></x-button> >> >> var ButtonPrototype = Object.create(HTMLElement.prototype) >> document.registerElement("x-button", {prototype: ButtonPrototype}) >> >> var SubmitButtonPrototype = Object.create(ButtonPrototype) >> document.registerElement("x-submit-button", {extends: "x-button", >> prototype: SubmitButtonPrototype}) >> >> >> Chrome's native registerElement doesn't seem to like this. It throws >> the following error. >> >> DOMException: Failed to execute 'registerElement' on 'Document': >> Registration failed for type 'x-submit-button'. The tag name specified >> in 'extends' is a custom element name. Use inheritance instead. >> >> >> The current Custom Element spec doesn't say any specific about this >> situation. Is Chrome wrong? Or is this something the spec should >> explicitly disallow? >> >
Received on Friday, 17 October 2014 20:34:34 UTC