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

From: Glenn Maynard [glenn@zewt.org]

> Using the event loop system just to change the way an exception is handled doesn't make any sense to me.

Really? To JavaScript programmers, it's the only thing that makes sense. There is no way in native JavaScript semantics to do the magic thing the web platform currently does, wherein (a) code is executed synchronously, but (b) exceptions thrown from that code bypass any surrounding `try`/`catch` blocks, and instead reach `window.onerror`.

>From the perspective of reducing magic in the platform, and providing basic primitives JavaScript programmers can use to polyfill and prollyfill future extensions to the platform, John's objection makes perfect sense. There is black C++ magic going on inside dispatchEvent, and it's unfortunate and surprising to JavaScript programmers.

We can't change it, for legacy reasons. But maybe we could expose that black magic to the platform for developers to use, so that it becomes less magic and more technology, that would allow us to build faithful `dispatchEvent` polyfills.

Received on Tuesday, 4 June 2013 15:20:10 UTC