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: Rick Waldron <waldron.rick@gmail.com>
Date: Mon, 2 Dec 2013 21:12:02 -0500
Message-ID: <CAHfnhfrh-2yVjJ14bvzyDmr47YOP=8bWf1LO-5QnhZQ-Ezwmig@mail.gmail.com>
To: Domenic Denicola <domenic@domenicdenicola.com>
Cc: "Marat Tanalin | tanalin.com" <mtanalin@yandex.ru>, "Tab Atkins Jr." <jackalmage@gmail.com>, Elliott Sprehn <esprehn@gmail.com>, "www-dom@w3.org" <www-dom@w3.org>
On Mon, Dec 2, 2013 at 9:08 PM, Domenic Denicola <
domenic@domenicdenicola.com> wrote:

> From: Rick Waldron [mailto:waldron.rick@gmail.com]
>
> > Yes, and it's not just you-the "single function/constructor/method that
> accepts a string and produces a node" is a common pattern implemented by
> all major libraries:
> >
> > Y.Node.create("<div>");
> > jQuery("<div>");
> > dojo.create("div");
> > new Element("div");
> > new Ext.dom.Element("div");
>
> And don't forget:
>
> document.createElement("div");
>
> (Wait, what just happened?!)
>

Well, I should've included that all but Ext.js allow a second argument that
is the attributes and properties to set. Ext.js and document.createElement
fall short there ;)

Rick
Received on Tuesday, 3 December 2013 02:12:51 UTC

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