Re: [DOM4] EventTarget as first class citizen

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...  ;)

-Boris

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