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

Re: Detecting and Creating Events

From: Sean Hogan <shogun70@westnet.com.au>
Date: Mon, 24 Aug 2009 10:14:36 +1000
Message-ID: <4A91DB6C.2030204@westnet.com.au>
To: Stewart Brodie <stewart.brodie@antplc.com>
CC: Garrett Smith <dhtmlkitchen@gmail.com>, DOM mailing list <www-dom@w3.org>
Stewart Brodie wrote:
> Garrett Smith <dhtmlkitchen@gmail.com> wrote:
>> The inability to easily and accurately detect events is a problem.
>> Programs want to know if an event is implemented at runtime. If it is,
>> then the feature can be used. If not, it a fallback stratety is in
>> order. Many new event types are being created and implemented. How can
>> a program feature-test to see if they are implemented?
> DocumentEvent.canDispatch() would seem to fit the bill, although it's not
> clear exactly what criteria this method is supposed to base its answer on
> right now.  You could suggest a clarification for the text and then you
> don't need to add all those new methods.
Yes, can we have a clarification of the text. I would hope that if 
canDispatch() was already implemented in Firefox-3.5  then 
document.canDispatch("mouseenter") would return false. But the current 
text is ambiguous enough that one could read it as as a test that the 
following would succeed:
    var e = document.createEvent("MouseEvent"); 
e.initEvent("mouseenter", false, true); document.body.dispatchEvent(e);
>> DOM 2 Events provides "createEvent(type)", but then required an
>> additional step initEvent or initMouseEvent. Method initMouseEvent
>> takes 15 arguments, none of them are memorable. It is painful to use.
> Honestly, how often does scripting wish to simulate UIEvents, MouseEvents,
> KeyboardEvents, MutationEvents or MutationNameEvents?  The only use case I
> can think of is a test harness that's trying to drive an application under
> test.

Well, simulating "mouseenter" / "mouseleave" would be useful, but in 
general that would be done in library.
I can't think of any other use-case for simulating events in the modules 
you listed.
Some of the basic events (change, submit, reset, load, error) and 
textInput could be useful for enhancing HTML elements.
For example, an <ul> could be used to emulate a <select>, with "change" 
events being dispatched as appropriate.
Received on Monday, 24 August 2009 00:15:31 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:15 UTC