Permalink
Browse files

Reusing the same function reference for resetting XHR events, should …

…fix a leak in IE6.

Also check for progressSupport when resetting loadstart and progress, throws in IE
  • Loading branch information...
cpojer committed Feb 23, 2011
1 parent 4c8640d commit cee4e5051f1843555f4bb3ae87210f891bd26607
Showing with 6 additions and 3 deletions.
  1. +6 −3 Source/Request/Request.js
@@ -16,7 +16,8 @@ provides: Request
(function(){
-var progressSupport = ('onprogress' in new Browser.Request);
+var empty = function(){},
+ progressSupport = ('onprogress' in new Browser.Request);
var Request = this.Request = new Class({
@@ -69,7 +70,8 @@ var Request = this.Request = new Class({
var status = xhr.status;
this.status = (status == 1223) ? 204 : status;
}.bind(this));
- xhr.onreadystatechange = function(){};
+ xhr.onreadystatechange = empty;
+ if (progressSupport) xhr.onprogress = xhr.onloadstart = empty;
clearTimeout(this.timer);
this.response = {text: this.xhr.responseText || '', xml: this.xhr.responseXML};
@@ -220,7 +222,8 @@ var Request = this.Request = new Class({
var xhr = this.xhr;
xhr.abort();
clearTimeout(this.timer);
- xhr.onreadystatechange = xhr.onprogress = xhr.onloadstart = function(){};
+ xhr.onreadystatechange = empty;
+ if (progressSupport) xhr.onprogress = xhr.onloadstart = empty;
this.xhr = new Browser.Request();
this.fireEvent('cancel');
return this;

2 comments on commit cee4e50

@ibolmo

This comment has been minimized.

Show comment Hide comment
@ibolmo

ibolmo Feb 23, 2011

Owner

What ever happened to Function.empty hehe.

Owner

ibolmo replied Feb 23, 2011

What ever happened to Function.empty hehe.

@cpojer

This comment has been minimized.

Show comment Hide comment
@cpojer

cpojer Feb 23, 2011

Owner

heh :D

Owner

cpojer replied Feb 23, 2011

heh :D

Please sign in to comment.