Skip to content

Commit

Permalink
Workaround IE's defficient handling of finally statements in Periodic…
Browse files Browse the repository at this point in the history
…alExecuter. [#696 state:resolved]
  • Loading branch information
tobie committed Jul 21, 2009
1 parent e41ccba commit 49090bc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG
@@ -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)

Expand Down
23 changes: 14 additions & 9 deletions src/lang/periodical_executer.js
Expand Up @@ -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;
}
}
}
}
Expand Down

0 comments on commit 49090bc

Please sign in to comment.