Re: More Ideas around DOM Constructors

On Fri, 20 Nov 2009 11:17:28 -0600
Jeff Schiller <codedread@gmail.com> wrote:

[snip]
 
> 1) Extend createElement(), createElementNS() with a new argument.
> This new argument should be a name-value map of attributes.  In JS
> this would look like:
> 
> createElement("circle", {cx: 40, cy:40, r:20, fill:"red"})
> 
> As before, this returns the element, which you could then
> appendChild/insertBefore, etc.

[snip]

I really like this idea. To me, this feels more like a single event to
create an element. When I do

   createElement( "circle" )
 
I feel like I've got a "not quite an object". It's not really created
until I make a bunch of set calls.

This has caused problems in every codebase I've ever worked on in other
languages.

Having the createElement completely fill out the attributes seems more
"intuitive" to me. I have used (and built) this kind of interface in
the past and it seems nicer.

One odd side-effect is that I often find I save a set of attributes in
a variable and reuse them.

G. Wade
-- 
Results are what you wanted, consequences are what you got.
                                                 -- Michael VanDusen

Received on Friday, 20 November 2009 23:14:28 UTC