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

On Mon, Jun 3, 2013 at 7:36 PM, John Barton <johnjbarton@google.com> wrote:

>  Well the current API only gives our part of the result state: why don't
> the exceptions propagate?
>
> Why can't we have "dispatch(event)" that both returns your boolean and
> propagates exceptions?
>

Sorry, I don't follow.  If it returns the boolean, then the event listeners
must be run before the function returns.  (The return value tells you
whether any event listener called event.preventDefault().)  I don't know
what "propagating exceptions" would mean here, since multiple exceptions
might be thrown (multiple listeners).  I suppose it could mean "run all
listeners, then rethrow the first seen exception", but that seems weird to
me.

(This is probably academic--I doubt that would be web-compatible
either--but I'm just trying to understand what you mean.)

I thought we established that dispatchEvent()'s behavior is not documented.
> What experience would I use other that years of experience in JavaScript?
>

I'm not sure what you're arguing, but improving documentation and specs is
much simpler than changing or adding new APIs (which would itself require
changes to specs).

You can do some of it yourself; MDN appears to be open to public editing:

https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.dispatchEvent

(I suspect MDN is used by web developers much more often than reading the
spec, so if it's author confusion you're worried about, adding a sentence
in here will probably have more effect than any change to the spec.)

-- 
Glenn Maynard

Received on Tuesday, 4 June 2013 01:00:47 UTC