- From: Marcos Caceres <w3c@marcosc.com>
- Date: Thu, 1 Mar 2012 01:16:17 +0000
- To: Boris Zbarsky <bzbarsky@mit.edu>
- Cc: www-dom@w3.org
On Thursday, 1 March 2012 at 00:51, Boris Zbarsky wrote: > 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. Pretty amazing, they did all that work over so many years and never really defined how it actually hooked together... > > > > > 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. Right. > > Does hooking the methods on EventTarget.prototype change the behavior > for nodes there or in Chrome? I'm not sure that is possible to test, as "EventTarget" is not in the global scope in Chrome or Opera (i.e., there is no window.EventTarget). I can see, through "javascript: alert(window.EventTarget)", that is does exist in FF. I tried messing with it in firefox, but it did nothing: http://jsfiddle.net/2t3kv/ > > 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... ;) > Yes, I guess that is the case.
Received on Thursday, 1 March 2012 01:16:49 UTC