Re: Exceptions in event listeners triggered by dispatchEvent().

On Mon, 3 Jun 2013, Jonas Sicking wrote:
>
> I think it would be great if dispatchEvent dispatched the event at
> end-of-microtask or some such.

The usual pattern when dispatching an event is:

   <something happens>
   dispatch an event to notify user code!
   was the event canceled? if not, do the default action

It would be weird if this wasn't synchronous. I'm not really sure how you 
would do the default action. Certainly it would mean that the default 
action was no longer in the same task as the <something happens>, which is 
weird. Think about browser events (either by analogy or as a concrete 
example, depending on whether you'd want this to apply to all events or 
only those dispatched from script): you click on a checkbox, its .value 
changes, an event is fired, and if it's canceled, the .value is changed 
back. It'd be pretty weird if this happened asynchronously.

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

Received on Monday, 17 June 2013 21:27:36 UTC