W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2012

Re: [DOM4] EventTarget as first class citizen

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 29 Feb 2012 19:51:15 -0500
Message-ID: <4F4EC803.9030101@mit.edu>
To: Marcos Caceres <w3c@marcosc.com>
CC: www-dom@w3.org
On 2/29/12 7:01 PM, Marcos Caceres wrote:
> I also had a very brief look at the DOM 2 and 3 specs, to get a bit of a legacy perspective, but that's just more confusing (they seem to assume some magic casting from Node to EventTarget… Java styles… which might explain why EventTarget is missing from the prototype chain in legacy implementations of DOM3). From DOM3 Core:

Yep. The old specs don't define how this should work at all.

>>> Node somehow transparently/silently inherits EventTarget.
>> No, it doesn't.
> Sorry, I'm not sure what you mean (or I've missed something or worded it wrongly).
> Looking at the console in Opera, when I do dir(a) it is says "NodePrototype (+)" and addEventListener and friends are listed under there.

Yes, which just means that all methods from EventTarget.prototype are 
copied onto Node.prototype.

Does hooking the methods on EventTarget.prototype change the behavior 
for nodes there or in Chrome?

> interestingly, it's the same with Window… it is also supposed to inherit from EventTarget, but it doesn't (EventTarget's methods are just part of Window…

Yes, Window inheriting from EventTarget is a recent spec change.

> so it's as if EventTarget doesn't exist at all for any Interface that inherits from it…

Or like you're reading not-yet-implemented brand-new specs...  ;)

Received on Thursday, 1 March 2012 00:51:48 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:18 UTC