W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2013

Re: Convenient way to create element and set its attributes at once

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Mon, 2 Dec 2013 10:52:43 -0800
Message-ID: <CAAWBYDC96yZaad8S1oonWbzCfS22hTjdhZ66QZ7oJGBsEXMz_Q@mail.gmail.com>
To: Domenic Denicola <domenic@domenicdenicola.com>
Cc: Elliott Sprehn <esprehn@gmail.com>, "Marat Tanalin | tanalin.com" <mtanalin@yandex.ru>, "www-dom@w3.org" <www-dom@w3.org>
On Mon, Dec 2, 2013 at 10:32 AM, Domenic Denicola
<domenic@domenicdenicola.com> wrote:
> From: Tab Atkins Jr. <jackalmage@gmail.com>
>> It would be useful for HTML to do the same, so you could call "new HTML.div(...)" instead of "new HTMLDivElement(...)".
>
> This seems like a really cool plan. (Although of course ES6 modules would be better, but, no need to hold up the platform waiting for them... namespaces are fine in the meantime.)

Agreed.

>> It would also let us establish a one-to-one constructor to tagname correspondence, so "HTML.h1()" works instead of "HTMLHeadingElement('h1',...)".
>
> I guess it would not be a constructor in that case though, i.e. you'd do `var myH1 = HTML.h1()` instead of `var myH1 = new HTML.h1()`, since otherwise you would break the `new X instanceof X` invariant.

Hm, I don't understand.  instanceof just walks the prototype chains,
and the functions denoted by "HTMLHeadingElement" and "HTML.h1" can
have the same prototype.  I suspect I'm missing something in your
statement.

~TJ
Received on Monday, 2 December 2013 18:53:39 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:21 UTC