W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2011

Re: Element.create(): a proposal for more convenient element creation

From: Glenn Maynard <glenn@zewt.org>
Date: Wed, 3 Aug 2011 11:46:50 -0400
Message-ID: <CABirCh_uZiX7ceOC782axHt1DVM7RhYw05OVscyQECN15q9=gg@mail.gmail.com>
To: Anne van Kesteren <annevk@opera.com>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, Aryeh Gregor <ayg@aryeh.name>, Maciej Stachowiak <mjs@apple.com>, WebApps WG <public-webapps@w3.org>
On Wed, Aug 3, 2011 at 3:34 AM, Anne van Kesteren <annevk@opera.com> wrote:

> On Tue, 02 Aug 2011 20:31:04 +0200, Tab Atkins Jr. <jackalmage@gmail.com>
> wrote:
>
>> Hmm, is everything exposed as on* attributes now?  If so, then yeah,
>> just do that; no need to mess around with a magic property in the
>> attributes bag.
>>
>
> This would still be magical as it is setting an IDL attribute rather than a
> content attribute.
>

What's the difference?  I'd expect this:

a = Element.create("a", {href: "http://link", onclick: function(e) { },
custom: "value" }, "link");

to be essentially equivalent to

a = document.createElement("a");
a.appendChild(document.createTextNode("link"));
attrs = {href: "http://link", onclick: function(e) { }, custom: "value" };
for(key in attrs) a[key] = attrs[key];

-- 
Glenn Maynard
Received on Wednesday, 3 August 2011 15:47:18 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:46 GMT