Created
December 28, 2012 07:12
-
-
Save anonymous/4395291 to your computer and use it in GitHub Desktop.
old IE shim for creating empty dict objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pre-ES5 IE version | |
var dict = (function() { | |
var PROPERTY_KEYS = [ | |
"hasOwnProperty", | |
"isPrototypeOf", | |
"propertyIsEnumerable" | |
"valueOf", | |
"toString", | |
"toLocaleString", | |
"constructor" | |
]; | |
var frame = document.createElement("iframe"); | |
document.body.appendChild(frame); | |
var proto = frame.contentWindow.Object.prototype; | |
document.body.removeChild(frame); | |
for (var i = 0, n = PROPERTY_KEYS.length; i < n; i++) { | |
delete proto[PROPERTY_KEYS[i]]; | |
} | |
function Dict() { } | |
Dict.prototype = proto; | |
function dict() { | |
return new Dict(); | |
} | |
return dict; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"propertyIsEnumerable",