W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2015

Re: ES6 and upgrading custom elements

From: Dimitri Glazkov <dglazkov@google.com>
Date: Tue, 6 Jan 2015 11:09:38 -0800
Message-ID: <CADh5Ky1w-eoLrv_JALKi+yh1PPSE8BcR8tDEDgv3qc9tqZYUKA@mail.gmail.com>
To: Anne van Kesteren <annevk@annevk.nl>
Cc: WebApps WG <public-webapps@w3.org>
On Tue, Jan 6, 2015 at 10:59 AM, Anne van Kesteren <annevk@annevk.nl> wrote:

> On Tue, Jan 6, 2015 at 7:54 PM, Dimitri Glazkov <dglazkov@google.com>
> wrote:
> > Right, that's why to create a valid custom element that subclasses
> > HTMLInputElement, you should use type extensions. With type extensions,
> the
> > HTMLInputElement is what's instantiated.
>
> But without using type extensions this will work (provided we sort out
> the other bits):
>
>   class X extends HTMLInputElement { ... }
>   document.registerElement("x-input", X)
>   var xinput = new X
>
> It seems sad to require type extensions (and therefore requiring a
> more complicated version of document.registerElement) for translating
> this into markup.
>

You shouldn't need anything more complicated:

class X extends HTMLInputElements { .. }
X.extends = "input" // additional line.
document.register("x-input", X)
var xinput = new X


>
> Having actual subclassing in JavaScript, but not for elements unless
> you use some sort of hack seems sad.
>

The type extensions is a hack, I agree :(

:DG<
Received on Tuesday, 6 January 2015 19:10:05 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:27:25 UTC