Allow clearInterval to clear it's own interval
As described in issue #655, the handler of an interval cannot successfully clear the same interval that generated it's invocation. Solve this issue by changing the order in which interval's handlers are called and then rescheduled to: first reschedule it and then call it. The actual order (call first then reschedule) produces that, during the execution of the interval's handler, the handler is not registered as a function to run after a timeout or interval ("scheduledFunctions"), because it was previously unregistered. Consequently, if the handler calls clearInterval, that function wont be able to find the handler and remove it completely.
This commit is contained in:
@@ -127,11 +127,12 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
||||
|
||||
for (var i = 0; i < funcsToRun.length; ++i) {
|
||||
var funcToRun = funcsToRun[i];
|
||||
funcToRun.funcToCall.apply(null, funcToRun.params || []);
|
||||
|
||||
if (funcToRun.recurring) {
|
||||
reschedule(funcToRun);
|
||||
}
|
||||
|
||||
funcToRun.funcToCall.apply(null, funcToRun.params || []);
|
||||
}
|
||||
} while (scheduledLookup.length > 0 &&
|
||||
// checking first if we're out of time prevents setTimeout(0)
|
||||
|
||||
Reference in New Issue
Block a user