Putting EventTarget on the prototype chain

There was a thread on webkit-dev recently (starting at
<https://lists.webkit.org/pipermail/webkit-dev/2011-June/017024.html>)
about changing WebKit’s JavaScript bindings to put EventTarget on the
prototype chain for every event target. The conclusion of the thread
on webkit-dev was that, WebKit implementation issues aside, we needed
more discussion and www-dom is a better venue for that.

Here is a brief summary of the opinions and observations of the earlier thread:

DOM Core is deliberately moving EventTarget into the prototype chain
for DOM nodes, and a bunch of other specs including Notifications,
Indexed DB, SVG and XHR already specify it this way too (was this by
accident or design?) However there are still many specs that specify
EventTarget as a mixin. Which way are the specs going? (Is this a
better question for public-webapps?)

Putting EventTarget on the prototype chain makes it easier to hook
addEventListener/removeEventListener/dispatchEvent by monkeypatching
EventTarget.prototype, and makes it easier to identify what things are
event targets. However EventTarget is really an abstract interface,
and hooking it globally might be of limited utility.

Dominic

Received on Wednesday, 15 June 2011 14:04:51 UTC