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

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Feb 2 13:19:31 PST 2008


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





------- Comment #3 from dhtmlkitchen at gmail.com  2008-02-02 13:19 PDT -------
bar == null is only true due to type conversion. bar should have the value
|undefined|

It's not name that's a problem, it's ID. 

In IE, you can't assign to a variable that was created from an element. Unless
you use |var| and declare a variable first. 

javascript:void( (function() { try { hork  = 1; } catch(ex) { alert(ex.message)
} })());

// fails because IE doesn't support |name|.
javascript:void( (function() { try { hork  = 1; } catch(ex) { alert(ex.name) }
})()); 

javascript:alert(Object.prototype.hasOwnProperty.call(window, "hork")); // true

Webkit may have tried to emulate this on a safer level. Create a property for
an element with an ID as part of window. Mark it ReadOnly.

Auto-window element props of ID:
 Webkit: ReadOnly
 IE: ReadOnly

Assigning to Auto-window props:
 Webkit: do nothing
 IE: throw Error

Binding Variables to Global Object props:
This means that in global scope/context  |this| is the global object. Variables
of the global object become properties:
 var x = 1;
   equivalent to:
 this.x = 1;

magic-prop: a property that was created automagically by the browser from an
element's ID.

Binding Variables of same-named magic-props to Global Object as Properties (use
var)
 IE: replace the default attributes that the variable was given. It's not
readonly after binding. 
 Webkit: Do not bind.

Assigning to window auto-properties (no var)
 IE: When assigning to a of window auto-prop, fail silently, as if it were
ReadOnly. 
 Webkit: allow assignment.

That is why usevar is available in Webkit. Webkit doesn't bind it as a
property.


-- 
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