Re: [DOM4] EventTarget as first class citizen

On Wednesday, 29 February 2012 at 21:26, Boris Zbarsky wrote:

> On 2/29/12 2:35 PM, Marcos Caceres wrote:
> > "a" now has "addEventListener" in its prototype chain. So:
>  
>  
>  
> Yes, but _where_?
This is a good question, maybe just bind the properties transparently to Object?  

Sounds like blasphemy, I know... but consider that DOM Elements already do this kind of thing. In Chrome, for example:

var a = document.createElement("a")

Then:  

a.__proto__ is "HTMLAnchorElement", whose __proto__ is "HTMLElement", whose __proto__ is "Element", whose __proto__ is "Node", whose __proto__ is "Object".  

But DOM4 says:  
interface Node : EventTarget {…}  

So I would have expected Node's __proto__ to be "EventTarget". But it is not… Node somehow transparently/silently inherits EventTarget.  

So maybe it could be the same with Object?… just sayin' there is precedence for doing this "silent" inheritance (though it ain't pretty).  


--  
Marcos Caceres
http://datadriven.com.au

Received on Wednesday, 29 February 2012 23:01:22 UTC