- From: Anne van Kesteren <annevk@annevk.nl>
- Date: Mon, 24 Dec 2012 10:38:01 +0100
- To: Boris Zbarsky <bzbarsky@mit.edu>
- Cc: www-dom@w3.org, Cameron McCormack <cam@mcc.id.au>, Bobby Holley <bholley@mozilla.com>
On Mon, Dec 24, 2012 at 1:07 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote: > Note also that Gecko will update the proto on some other things that hang > off Elements as well (whichever ones we've thought about), but not all of > them. It's a bit ad-hoc at the moment. Ah yes, such as DOMTokenList. And other specifications can potentially introduce more of those. Bah. (Maybe we can make "associated" an actual definition in DOM and specifications say "node can have/has an *associated* X object" and DOM can say to change the prototype of all *associated* objects...) >> How do I go about defining replacing the proto of an element? > > That's a good question. It at least partially depends on how this needs to > interact with web components. I don't really understand the web components angle, because I don't really understand the inner workings of web components. >> Are there any other places where this happens in the platform? > > Not that I know of, apart from adoptNode and document.open(). > > Note that there's the question of what the right proto is to use for the > element to start with. I _think_ that's meant to be defined in WebIDL > section 4.6, which says: > > Every platform object is associated with a global environment, just > as the initial objects are. It is the responsibility of > specifications using Web IDL to state which global environment (or, > by proxy, which global object) each platform object is associated > with. > > and then: > > The value of the internal [[Prototype]] property of the platform > object is the interface prototype object of the primary interface > from the platform object’s associated global environment. > > I will bet $50 that there are no specs that actually define which global > environment their objects are associated with. ;) The DOM spec certainly > doesn't seem to, and I think it had the best chance of them all. This was discussed a few times before, I believe Ian was holding out for a default and I have been holding out for HTML taking the lead (my usual approach to new territory). But given that it can actually change we should probably do one better. In the document.open() case I guess we'd want to change the prototype of every object, including e.g. XMLHttpRequest, so we have the highest chance of being able to garbage collect the previous window? (Although what if someone extended the prototype before document.open() was invoked?) >> Is the right place in DOM or should IDL provide a hook for it? > > I think WebIDL should provide a hook for changes to the global environment > an object is associated with. And then we should coordinate between WebIDL > and Web components for how they should interact. And specs will need to > define the global environment bit, including when (or if) it changes. I hope that for the non-node scenario we can keep this relatively straightforward... By the way, ES6 will define __proto__: https://people.mozilla.com/~jorendorff/es6-draft.html#sec-B.3 -- http://annevankesteren.nl/
Received on Monday, 24 December 2012 09:38:29 UTC