- From: Cameron McCormack <cam@mcc.id.au>
- Date: Thu, 23 Jun 2011 22:57:27 +1200
- To: Anne van Kesteren <annevk@opera.com>
- Cc: Doug Schepers <schepers@w3.org>, "www-dom@w3.org" <www-dom@w3.org>
Anne van Kesteren:
> http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-event-init
>
> (With this new init() method the only thing you need to do for a new
> event interface is to define an event initialization dictionary and
> its mapping to the variables of your event interface.)
Minor suggestion: name the dictionaries something other than *Event,
because that seems like an event interface name. EventInitializer or
EventParameters (and then CustomEventInitializer or
CustomEventParameters, etc.).
Also, I wonder if the event type should just be a plain argument outside
the dictionary. I think every event you dispatch needs a type.
var evt = document.createEvent("MouseEvent");
evt.init("click", { clientX: 100, clientY: 150 });
looks OK to me.
Does it make sense to provide event interfaces with constructors? A
pattern like:
elt.dispatchEvent(new MouseEvent("click", { clientX: 100,
clientY: 150 });
looks even better. :-)
--
Cameron McCormack ≝ http://mcc.id.au/
Received on Thursday, 23 June 2011 10:58:02 UTC