> That's basically what the Global Scope Polluter does. That's certainly how I plan to implement it in Gecko in the WebIDL bindings: Window.prototype.__proto__ will be a proxy which will do all the weird stuff the GSP has to do.
In FF 14, I’m getting the following results (if there is an element whose ID is "foo"):
$ "foo" in window
false
$ foo
ReferenceError: foo is not defined
$ window.foo // (*)
[object HTMLDivElement]
Element referenced by ID/NAME in the global scope. Use W3C standard document.getElementById() instead.
$ foo // (**)
undefined
Element referenced by ID/NAME in the global scope. Use W3C standard document.getElementById() instead. @ Web Console:1
$ "foo" in window
true
That looks like what you described: The Global Scope Polluter auto-creates foo after the read access (*). However, (**) puzzles me: A getter for foo seems to be called (as a warning is displayed), but it returns `undefined`. How come?
Also interesting: window instanceof EventTarget holds, but EventTarget.prototype is not in protos(window), an array created by:
function protos(obj) {
var chain = [];
while (obj) {
chain.push(obj);
obj = Object.getPrototypeOf(obj);
}
return chain;
}
Axel
--
Dr. Axel Rauschmayer
axel@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com