Workaround IE's defficient handling of finally statements in PeriodicalExecuter. [#696 state:resolved]

This commit is contained in:
Tobie Langel 2009-07-21 17:18:43 +02:00
parent e41ccba6d8
commit 49090bc957
2 changed files with 15 additions and 10 deletions

View File

@ -1,4 +1,4 @@
* Re-throw error in otherwise-empty `catch` clause so that `PeriodicalExecuter` does not suppress exceptions. (Samuel Lebeau)
* Fix `PeriodicalExecuter` so that it no longer suppresses exceptions. [#696 state:resolved] (Samuel Lebeau, Yaffle)
* Fix issue related to escaping of selectors for querySelectorAll. [#559 state:resolved] (Jorn Holm)

View File

@ -49,15 +49,20 @@ var PeriodicalExecuter = Class.create({
onTimerEvent: function() {
if (!this.currentlyExecuting) {
try {
this.currentlyExecuting = true;
this.execute();
} catch(e) {
// Catch clause for clients that don't support try/finally.
throw e;
}
finally {
this.currentlyExecuting = false;
if (!this.currentlyExecuting) {
// IE doesn't support `finally` statements unless all errors are caught.
// We mimic the behaviour of `finally` statements by duplicating code
// that would belong in it. First at the bottom of the `try` statement
// (for errorless cases). Secondly, inside a `catch` statement which
// rethrows any caught errors.
try {
this.currentlyExecuting = true;
this.execute();
this.currentlyExecuting = false;
} catch(e) {
this.currentlyExecuting = false;
throw e;
}
}
}
}