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

Rick Waldron <[email protected]>
Newsgroups gmane.comp.web.dom.general
Message-ID <CAHfnhfrh-2yVjJ14bvzyDmr47YOP=8bWf1LO-5QnhZQ-Ezwmig@mail.gmail.com>
On Mon, Dec 2, 2013 at 9:08 PM, Domenic Denicola <
[email protected]> wrote:

> From: Rick Waldron [mailto:[email protected]]
>
> > 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.