- From: Domenic Denicola <notifications@github.com>
- Date: Fri, 20 May 2016 14:23:07 -0700
- To: heycam/webidl <webidl@noreply.github.com>
- Cc:
- Message-ID: <heycam/webidl/issues/125@github.com>
Originally: https://github.com/whatwg/html/issues/1289 ### The problem `HTMLElement` has a constructor, specifically designed so that you can do ```js class X extends HTMLElement {} customElements.define("x-x", X); new X(); ``` However, our intention was that you should also be able to do ```js class Y extends HTMLParagraphElement {} customElements.define("y-y", Y, { extends: "p" }); new Y(); ``` But this currently fails since, per Web IDL, the first step of `HTMLParagraphElement`'s constructor is to throw a `TypeError`. ### Proposed solution Change the first step of all Web IDL interface object's construction behavior to only throw if they are not a derived interface. Otherwise, do the equivalent of `super(...arguments)`. This means all subclasses of things that are constructible automatically get a pass-through constructor. Subclasses of things without constructors also get a pass-through constructor, but since the superclass constructor throws, the subclass constructor will continue throwing. As part of this, I'd update the specification for interface objects to have modern [[Construct]] and [[Call]] definitions instead of just [[Call]]. ### Repercussions I'm not sure if there are any interface on the platform that currently have a constructor, but which have subclasses that are not constructible. If such interfaces exist, their subclasses would become constructible. This seems unlikely to be a problem even if such interfaces do exist, but it's hard to say for sure. ----- I'm happy to do a PR for this but would like some feedback on whether it will be accepted. --- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/heycam/webidl/issues/125
Received on Friday, 20 May 2016 21:23:34 UTC