W3C home > Mailing lists > Public > www-svg@w3.org > November 2009

Re: More Ideas around DOM Constructors

From: G. Wade Johnson <gwadej@anomaly.org>
Date: Fri, 20 Nov 2009 17:13:44 -0600
To: Jeff Schiller <codedread@gmail.com>, www-svg <www-svg@w3.org>
Message-ID: <20091120171344.10b81ba5@sovvan>
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 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:43 GMT