Fixing 'compatibility.js' load order; add Object.keys emulation

This commit is contained in:
notmasteryet 2011-10-29 16:00:13 -05:00
parent a7a6e41ec6
commit 0912959503
2 changed files with 16 additions and 1 deletions

View file

@ -83,6 +83,21 @@
};
})();
// Object.keys() ?
(function checkObjectKeysCompatibility() {
if (typeof Object.keys !== 'undefined')
return;
Object.keys = function objectKeys(obj) {
var result = [];
for (var i in obj) {
if (obj.hasOwnProperty(i))
result.push(i);
}
return result;
};
})();
// No XMLHttpRequest.response ?
(function checkXMLHttpRequestResponseCompatibility() {
var xhrPrototype = XMLHttpRequest.prototype;