[whatwg] Exposing EventTarget to JavaScript

Ian Hickson ian at hixie.ch
Fri Apr 24 12:44:00 PDT 2009


On Fri, 24 Apr 2009, Erik Arvidsson wrote:
>
> Almost all JavaScript libraries and web apps of moderate size end up 
> reimplementing events for their UI toolkits or for messaging between 
> different parts of their application. To help out with this scenario it 
> would be good if an implementation of the EventTarget interface could be 
> exposed to JavaScript. This would mean that JavaScript can instantiate 
> and extend event targets and dispatch events to these objects would work 
> just like it does for DOM elements today.

This seems like a reasonable idea, but would be more appropriately made 
available in the DOM3 Events specification, being developed in the W3C
public-webapps working group.


On Fri, 24 Apr 2009, Kristof Zelechovski wrote:
>
> As a reminder, the syntax {new Option()} (Netscape DOM) is deprecated to the
> syntax {document.createElement("OPTION")} (W3C DOM).

This isn't correct; new Option() is perfectly valid and not deprecated.


On Fri, 24 Apr 2009, Alex Russell wrote:
>
> As we discussed off-list, I absolutely support this, but with shorter 
> names. The DOM names for these interfaces are dumb. Idiomatic JS prefers 
> short over long, so the above example should be able to be written as:
> 
> var et = new EventTarget();
> et.listen("foo", fun); // default phase to "false"
> et.dispatch(evtObj);
> 
> Similarly, the DOM interface should be modified to allow these aliases 
> for the existing names.

I encourage you to bring this up on the public-webapps list.


On Fri, 24 Apr 2009, Giovanni Campagna wrote:
> 
> This should not work. This is because the DOM event system (used for 
> elements) is different from the scripting event system (used for 
> windows, xmlhttprequest, workers, etc.). The former requires a document 
> through which the event flows (capture - target - bubble phases). No 
> document => no event.

This does not appear to be accurate either, though DOM3 Events maybe needs 
to be made clearer on the topic.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list