[Webkit-unassigned] [Bug 17146] global variable declarations should shadow window properties from id'd elements

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Feb 2 17:03:48 PST 2008


http://bugs.webkit.org/show_bug.cgi?id=17146





------- Comment #8 from dhtmlkitchen at gmail.com  2008-02-02 17:03 PDT -------
 Webkit:
loading: loading
'projectname' in window: true
 projectname: undefined
 novar 1
 hork [object HTMLInputElement]
 usevar: [object HTMLInputElement] 

IE:
loading: interactive
'projectname' in window: true
 projectname: undefined
 novar [object]
 hork [object]
 usevar: undefined

IE, novar is [object] -- that's the element that would be projectname in
Google'  createProject.

IE doesn't find |novar| on the Variable object; it goes to assign it to window,
but this fails because |novar| is some weird readonly magic-prop. If IE is
adding members to the global object, it removes the ReadOnly. That is why we
have |"projectname"in window|

// projectname got added to the window from a the Variable object, and
// in the process, lost its ReadOnly 
javascript:alert( Object.prototype.hasOwnProperty.call(window, "projectname"))

You can try over and over: hork = 1;

No matter what, IE will keep hork as [object].

var hork = 1 is different in IE. hork is added as a member of the global object
(window.hork == 1); 

Webkit, novar is 1. It succeeds in assignment.
But usevar is [HTMLInputElement]. |usevar| did not get added to the window. 

Webkit did add |projectname| to the Variable object, and it was added as a
member of the global object.

So why did |usevar| not get created as a window property? You call this "not
shadowing" but there is no prototype chain from window > Variable object;
nothing to shadow.

In IE |usevar| is undefined. This is because IE7 uses properties of the
Variable object as properties of the global object.

(In reply to comment #6)
> Ah right, it is id -- although the problem is still the fact that we don't
> allow shadowing.

Variables are init'd with |undefined|, correct.

Here's my understanding: 
Global Variables don't shadow window properties. Global variables are created
as members of the global object; they're created as variables and bound as
properties.

There's no shadowing. Values get replaced, but in IE, the ReadOnly attribute
gets changed in the process.

> 


-- 
Configure bugmail: http://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list