HTML and CSS Reference
In-Depth Information
Internet Explorer (including version 8) has a peculiar bug concerning the
DontEnum attribute—any property on an object that has a property by the same
name anywhere on its prototype chain that has DontEnum will act as though it has
DontEnum as well (even though it should be impossible to have DontEnum on a
user-provided object). This means that if you create an object and shadow any of the
properties on Object.prototype , neither of these properties will show up in a
for-in loop in Internet Explorer. If you create an object of any of the native and
host types, all the properties on the respective prototype chains with DontEnum
will magically disappear from a for-in loop, as seen in Listing 7.11.
Listing 7.11 Overriding properties with DontEnum
TestCase("PropertyEnumerationTest", {
"test should enumerate shadowed object properties":
function () {
var object = {
// Properties with DontEnum on Object.prototype
toString: "toString",
toLocaleString: "toLocaleString",
valueOf: "valueOf",
hasOwnProperty: "hasOwnProperty",
isPrototypeOf: "isPrototypeOf",
propertyIsEnumerable: "propertyIsEnumerable",
constructor: "constructor"
};
var result = [];
for (var property in object) {
result.push(property);
}
assertEquals(7, result.length);
},
"test should enumerate shadowed function properties":
function () {
var object = function () {};
// Additional properties with DontEnum on
//Function.prototype
object.prototype = "prototype";
object.call = "call";
object.apply = "apply";
 
Search WWH ::




Custom Search