W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2013

Class side inheritance in WebIDL (was Re: [webcomponents]: Platonic form of custom elements declarative syntax)

From: Erik Arvidsson <arv@chromium.org>
Date: Thu, 11 Apr 2013 12:52:51 -0400
Message-ID: <CAJ8+Gog2c-XrMtME=7mWTRp0b3Q1F5nEkwQO7PBLBtHLcT_4yg@mail.gmail.com>
To: Allen Wirfs-Brock <allen@wirfs-brock.com>
Cc: Boris Zbarsky <bzbarsky@mit.edu>, public-webapps <public-webapps@w3.org>, "public-script-coord@w3.org" <public-script-coord@w3.org>, Cameron McCormack <cam@mcc.id.au>
ES6 defines class side inheritance. We should update WebIDL to do the same
to align them.

On Thu, Apr 11, 2013 at 12:50 PM, Allen Wirfs-Brock
<allen@wirfs-brock.com>wrote:

>
> On Apr 11, 2013, at 9:32 AM, Boris Zbarsky wrote:
>
> > On 4/11/13 12:23 PM, Allen Wirfs-Brock wrote:
> >> So why don't you make "register" a static method on HTMLElement and then
> >> define the <element> semantics so it automatically does:
> >>     MyElement.register()
> >>
> >> This would normally invoke the inherited static method
> >
> > I lost track of something here.  Why would it do that?  Does MyElement
> have Element on its proto chain?  MyElement.prototype certainly has
> Element.prototype on _its_ proto chain, but that's a separate concern from
> what happens with the interface objects...  Is this something that ES6
> classes define differently from current WebIDL and implementations, and if
> so, do we need to align the two somehow?
>
> Yes ES6 has "class-side" inheritance.  The ES5 equivalent for:
>
>    class Sub extends Super {
>        constructor() {/*constructor body */ }
>        method1 () {}
>        static method2 {}
>    }
>
> is:
>
>   function Sub() {/*constructor body */ }
>   Sub.__proto__ = Super;
>   Sub.prototype = Object.create(Super.prototype);
>   Sub.prototype.method1 = function method1() {};
>   Sub.method2 = function method2 () {};
>
>
> Sub.foo looks first looks for a own property on Sub, then on Super, etc.
>
> Allen
>
>
>
>


-- 
erik
Received on Thursday, 11 April 2013 16:53:38 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:37:48 UTC