[Bug 5850] JS global object

http://www.w3.org/Bugs/Public/show_bug.cgi?id=5850





--- Comment #16 from Adam Barth <w3c@adambarth.com>  2008-07-18 15:11:37 ---
> So if i have a Window object |window|, and I do:
> 
>    var x = window.foo;
> 
> ...where "foo" is some object or function, and then I navigate |window|, and
> then I call x() or access x.bar, does that access the original object's foo? Or
> what?

Yes.  Only references to the object pointed to by |window| get magically
changed to the new window object.

> I don't want to specify something that says that "all the references now point
> to a different object". That's weird. It's the same object in every sense that
> you can check from script.

Except for when you access properties of the object via the scope chain.  For
example, after navigation |foo| and |window.foo| will give different answers in
the global scope because the first comes off the scope chain whereas the second
gets indirected through the window shell.

> You can't ever get a reference to the underlying
> object. So I think it makes more sense to define Window as an object that
> forwards everything to an underlying object and just having that object change
> as you traverse back and forth.

That's fine.  The important bit is that the underlying object sits atop the
scope chain and ECMAScript thinks its the global object for the purposes of
computing prototypes, etc.

> But then we have:
> 
>    (function() { return this })()
> 
> ...and this breaks down, unless we override ECMA 262 as well, which seems
> unwise.

Why does this break down?  I added this to test03.html and it appears to behave
just like |window|.  That is, you get a reference to the window shell.


-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Friday, 18 July 2008 15:12:11 UTC