Created
January 26, 2011 01:01
-
-
Save paulbaumgart/796032 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
_XMLHttpRequest = XMLHttpRequest; | |
XMLHttpRequest = function () { | |
Object.defineProperty(this, | |
"__onreadystatechange", | |
{value: null, | |
writable: true, | |
enumerable: false}); | |
Object.defineProperty(this, | |
"onreadystatechange", | |
{get: (function() { return this.__onreadystatechange; }), | |
set: (function(val) { | |
if (this.__onreadystatechange && typeof this.__onreadystatechange.call === "function") | |
this.removeEventListener("readystatechange", this.__onreadystatechange); | |
this.__onreadystatechange = val; | |
if (this.__onreadystatechange && typeof this.__onreadystatechange.call === "function") | |
this.addEventListener("readystatechange", this.__onreadystatechange); | |
}), | |
enumerable: true}); | |
} | |
XMLHttpRequest.prototype = new _XMLHttpRequest(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does it not work as expected? There is no call property on the XHR object:
_XMLHttpRequest = XMLHttpRequest
function XMLHttpRequest() { [native code] }
_XMLHttpRequest.call
undefined