W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2011

Re: [DOMCore] fire and dispatch

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Fri, 25 Feb 2011 09:47:54 -0800
Message-ID: <AANLkTi=wE=GdHXWUe2vNfhVWF975+VCvhwg0gsfb7a4k@mail.gmail.com>
To: Anne van Kesteren <annevk@opera.com>
Cc: WebApps WG <public-webapps@w3.org>
On 2/25/11, Anne van Kesteren <annevk@opera.com> wrote:
> On Fri, 25 Feb 2011 04:05:44 +0100, Garrett Smith <dhtmlkitchen@gmail.com>
> wrote:
>> OK. Why not expose a generic version of `fire` to the scripting
>> environment?
> I do not know of any research (or have done any myself) as to how often
> such a feature might be useful for authors. While firing an event is
> currently a series of steps (using proposed optional arguments):
>    var e = document.createEvent("Event")
>    e.initEvent("test")
>    dispatchEvent(e)
> ... it is not hugely complicated. (We could even make the argument to
> createEvent optional too and default it to "Event".) I could imagine
> having something like EventTarget.fireEvent(name) but if you want to get a
> little beyond the basics you will remain stuck with creating the event
> yourself.
Your example is simple. But some common cases of synth events are
complicated. UI Events aren't so bad but MouseEvents and especially
TouchEvents are a lot of work to synthesize.

Most cases for synth events are for testing -- feature test or unit test.

EventTarget.fireEvent(type[, options]);
Received on Friday, 25 February 2011 17:51:21 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:30 UTC