Reflection of global bindings

David Bruant bruant.d at gmail.com
Sat Dec 15 09:21:47 PST 2012


Hi,

On public-script-coord, Boris Zbarsky showed an example [1] where a 
global variable is var-defined and then observed to be absent from the 
global object it was attached to (because the WindowProxy has changed of 
underlying window object).

The careful ECMAScript 5.1 reader knows that global var-defined 
variables are supposed to be reflected as own non-configurable 
properties of the global object. Reflecting the property as such commits 
the object to keep the property forever which, as we've seen in Boris 
example, is not compatible with how the web works.

I don't think it'll be possible to change how global objects in 
same-origin iframes work nor relax ES5 invariants; so my proposal is to 
have var/let/const/function global declarations *reflected* as 
configurable, but acting as if they were not.
This would also require a couple of changes in the spec and consequently 
JS engines and certainly test262.
Other proposals welcome, of course.

David

[1] 
http://lists.w3.org/Archives/Public/public-script-coord/2012OctDec/0328.html


More information about the es-discuss mailing list