Use a closure with a private variable for $.cache's requests.
This commit is contained in:
parent
606875c292
commit
9f3b9a2127
@ -369,9 +369,11 @@
|
||||
r.send(form);
|
||||
return r;
|
||||
},
|
||||
cache: function(url, cb) {
|
||||
var req, reqs, _base;
|
||||
reqs = (_base = $.cache).requests || (_base.requests = {});
|
||||
cache: (function() {
|
||||
var reqs;
|
||||
reqs = {};
|
||||
return function(url, cb) {
|
||||
var req;
|
||||
if (req = reqs[url]) {
|
||||
if (req.readyState === 4) {
|
||||
cb.call(req);
|
||||
@ -399,7 +401,8 @@
|
||||
});
|
||||
req.callbacks = [cb];
|
||||
return reqs[url] = req;
|
||||
},
|
||||
};
|
||||
})(),
|
||||
cb: {
|
||||
checked: function() {
|
||||
$.set(this.name, this.checked);
|
||||
|
||||
@ -295,8 +295,9 @@ $.extend $,
|
||||
$.extend r.upload, upCallbacks
|
||||
r.send form
|
||||
r
|
||||
cache: (url, cb) ->
|
||||
reqs = $.cache.requests or= {}
|
||||
cache: (->
|
||||
reqs = {}
|
||||
(url, cb) ->
|
||||
if req = reqs[url]
|
||||
if req.readyState is 4
|
||||
cb.call req
|
||||
@ -311,6 +312,7 @@ $.extend $,
|
||||
onerror: -> delete reqs[url]
|
||||
req.callbacks = [cb]
|
||||
reqs[url] = req
|
||||
)()
|
||||
cb:
|
||||
checked: ->
|
||||
$.set @name, @checked
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user