prototype: Prevent memory leaks in Ajax.PeriodicalUpdater. Closes #10049
This commit is contained in:
parent
c371096a71
commit
23823048d1
@ -1,3 +1,5 @@
|
||||
* Make Ajax.Updater clone its options hash before modifying it. Prevents memory leaks in Ajax.PeriodicalUpdater. Closes #10049 [Mislav Marohnić, Tobie Langel].
|
||||
|
||||
* Remove useless variable in Selector.handlers.child. Closes #10006 [kuriyama]
|
||||
|
||||
* Don't redeclare previously declared variables. Closes #10007 [kuriyama]
|
||||
|
10
src/ajax.js
10
src/ajax.js
@ -306,11 +306,11 @@ Ajax.Updater = Class.create(Ajax.Request, {
|
||||
failure: (container.failure || (container.success ? null : container))
|
||||
};
|
||||
|
||||
options = options || { };
|
||||
options = Object.clone(options);
|
||||
var onComplete = options.onComplete;
|
||||
options.onComplete = (function(response, param) {
|
||||
options.onComplete = (function(response, json) {
|
||||
this.updateContent(response.responseText);
|
||||
if (Object.isFunction(onComplete)) onComplete(response, param);
|
||||
if (Object.isFunction(onComplete)) onComplete(response, json);
|
||||
}).bind(this);
|
||||
|
||||
$super(url, options);
|
||||
@ -332,10 +332,6 @@ Ajax.Updater = Class.create(Ajax.Request, {
|
||||
}
|
||||
else receiver.update(responseText);
|
||||
}
|
||||
|
||||
if (this.success()) {
|
||||
if (this.onComplete) this.onComplete.bind(this).defer();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -161,7 +161,19 @@
|
||||
});
|
||||
});
|
||||
}},
|
||||
|
||||
|
||||
testUpdaterOptions: function() {with(this) {
|
||||
var options = {
|
||||
method: 'get',
|
||||
asynchronous: false,
|
||||
evalJS: 'force',
|
||||
onComplete: Prototype.emptyFunction
|
||||
}
|
||||
var request = new Ajax.Updater("content", "fixtures/hello.js", options);
|
||||
request.options.onComplete = function() {};
|
||||
assertIdentical(Prototype.emptyFunction, options.onComplete);
|
||||
}},
|
||||
|
||||
testResponders: function(){with(this) {
|
||||
// check for internal responder
|
||||
assertEqual(1, Ajax.Responders.responders.length);
|
||||
|
Loading…
Reference in New Issue
Block a user