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 12:39:46 -0800
Message-ID: <CAAWBYDC-qYh=o6tPsTCo+jwstUY59p4J7mgdO0BQbsSyGQCnvw@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: "www-dom@w3.org" <www-dom@w3.org>
On Mon, Dec 2, 2013 at 11:53 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 12/2/13 2:08 PM, Tab Atkins Jr. wrote:
>>
>> You can satisfy #1 and #3 if you implement things in the obvious way:
>>
>> HTML.h1 = function(...args) { return new HTMLHeadingElement("h1",
>> ...args); };
>> HTML.h1.prototype = HTMLHeadingElement.prototype;
>
>
> No.  instanceof walks up the proto chain but then looks for the .constructor
> of the things on the proto chain matching the RHS.

Huh.  I did not realize that.

Well, anyway, given that the goal is conciseness, having a plain
function that doesn't require "new" is probably good in any case.

~TJ
Received on Monday, 2 December 2013 20:40:37 UTC

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