-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove old callbacks in Request.JSONP.request_map #1315
Conversation
since that's not official API (the stored responses) BC should be ignored On Tuesday, August 11, 2015, Sergio Crisostomo notifications@github.com
Dimitar Christoff "JavaScript is to JAVA what hamster is to ham" |
Agreed with @DimitarChristoff |
Nice feedback! will update soonish and ping back. |
61d5759
to
b600ac5
Compare
@arian @DimitarChristoff updated |
@@ -119,19 +119,20 @@ Request.JSONP = new Class({ | |||
return !!this.running; | |||
}, | |||
|
|||
clear: function(){ | |||
clear: function(index){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm.
What if the index isn't passed in? If it's required, that's a breaking change.
What if the index passed in isn't the running request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not breaking because worst case scenario, it will just try to delete an undefined property.
I have a better fix which does not change the API - storing the index within the script tag, then auto deleting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff. Might suggest we used data-jsonp-index or something rather than the element attribute, but whatever, it doesn't matter really.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i considered it but it's so short lived - initially even thought of storage but that meant storage gc when element is removed. i'd agree about data-prop
as it ought to be slightly cheaper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
easier fix still. one liner
Request.JSONP.request_map['request_' + index] = function(){
delete Request.JSONP.request_map['request_' + index];
this.success(arguments, index);
}.bind(this);
so
+ delete Request.JSONP.request_map['request_' + index];
b600ac5
to
37d2406
Compare
Updated again. No |
@SergioCrisostomo check master...DimitarChristoff:SergioCrisostomo-fix1293 - missed an index and such. |
Nice! Yeah, that index was already there from before and is unused. Will cherry pick your work and use it. thanks! Sent from my iPhone
|
remove old callbacks in Request.JSONP.request_map
fixes #1293
Add option to remove old
Request.JSONP.request_map
callbacks. Defaults tofalse
to be BC.