W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2011

Re: [DOM4]: Element.create

From: Anne van Kesteren <annevk@opera.com>
Date: Sat, 17 Sep 2011 09:37:15 +0200
To: "Jonas Sicking" <jonas@sicking.cc>, "Ian Hickson" <ian@hixie.ch>
Cc: "www-dom@w3.org" <www-dom@w3.org>
Message-ID: <op.v1xzgdjg64w2qv@annevk-macbookpro.local>
On Sat, 17 Sep 2011 05:54:00 +0200, Ian Hickson <ian@hixie.ch> wrote:
> IIRC, one of the e-mails in the original proposal had a suggestion for a
> way to do event handlers in a better way.

Suggested thus far:

1. Have a magic property called "events" like MooTools that takes an  
object of events and their associated handler.

2. Have a magic set of properties that all start with "on" and set them  
directly as properties rather than attributes.

3. Have an additional argument that takes an object of events and their  
associated handler.


I have a slight preference for 3 if we can get overloading to work. Is  
overloading able to distinguish between objects and arrays? Would be nice  
that if you just want to create an element with a child you do not have to  
use the middle argument.

Examples:

   Element.create("p", "Text content.")
   Element.create("p", [child1, child2])
   Element.create("q", {cite:"about:blank"}, "Like anyone uses <q>!")
   Element.create("a", {href:"./"}, {click:navigate}, "Home")


-- 
Anne van Kesteren
http://annevankesteren.nl/
Received on Saturday, 17 September 2011 07:37:50 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:08 GMT