Re: [DOM4]: Element.create

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 UTC