Permalink
Browse files

Fixed Request.JSONP racecondition in firefox when using option link: …

…cancel

The callbacks where run in firefox, even when Request.JSONP.clear() had been
executed. Solved by adding code in the .clear()-function which replace the
anonymous function reference in Request.JSONP.request_map with another
anonymous function which deletes its own reference upon execution
  • Loading branch information...
1 parent 7065c9a commit 418c16a37c2040bddaf4739d507f80bfe60b0f85 @jtrosby committed Oct 18, 2011
Showing with 12 additions and 0 deletions.
  1. +12 −0 Source/Request/Request.JSONP.js
@@ -105,6 +105,7 @@ Request.JSONP = new Class({
success: function(args, index){
if (!this.running) return;
+ this.removeCallback(index);
this.clear()
.fireEvent('complete', args).fireEvent('success', args)
.callChain();
@@ -124,6 +125,13 @@ Request.JSONP = new Class({
if (this.script){
this.script.destroy();
this.script = null;
+
+ var index = this.index;
+ if(Request.JSONP.request_map['request_'+index] != undefined) {
+ Request.JSONP.request_map['request_'+index] = function() {
+ this.removeCallback(index);
+ }.bind(this)
+ }
}
return this;
},
@@ -134,6 +142,10 @@ Request.JSONP = new Class({
this.fireEvent('timeout', [this.script.get('src'), this.script]).fireEvent('failure').cancel();
}
return this;
+ },
+
+ removeCallback: function(index) {
+ delete Request.JSONP.request_map['request_'+index];
}
});

0 comments on commit 418c16a

Please sign in to comment.