diff options
author | Wilson Page <wilsonpage@me.com> | 2013-10-25 17:07:43 +0100 |
---|---|---|
committer | Wilson Page <wilsonpage@me.com> | 2013-10-25 17:07:43 +0100 |
commit | 03639d393df14e004f55831691a70570310fb9d5 (patch) | |
tree | c1195fc267f2532e5c89e06733c9e60a07a36c51 | |
parent | 3cdcef0b54d1f5c357faddfdea22c08b85f702a7 (diff) | |
download | fastdom-03639d393df14e004f55831691a70570310fb9d5.zip fastdom-03639d393df14e004f55831691a70570310fb9d5.tar.gz fastdom-03639d393df14e004f55831691a70570310fb9d5.tar.bz2 |
Catch errors inside runBatch and re-run to prevent exceptions blocking the flush
-rw-r--r-- | index.js | 34 |
1 files changed, 23 insertions, 11 deletions
@@ -232,30 +232,42 @@ */ FastDom.prototype.flush = function(list) { var id; + while (id = list.shift()) { this.run(this.batch.hash[id]); } }; /** - * Runs any read jobs followed - * by any write jobs. + * Runs any 'read' jobs followed + * by any 'write' jobs. + * + * We run this inside a try catch + * so that if any jobs error, we + * are able to recover and continue + * to flush the batch until it's empty. * * @api private */ FastDom.prototype.runBatch = function() { + try { - // Set the mode to 'reading', - // then empty all read jobs - this.batch.mode = 'reading'; - this.flush(this.batch.read); + // Set the mode to 'reading', + // then empty all read jobs + this.batch.mode = 'reading'; + this.flush(this.batch.read); - // Set the mode to 'writing' - // then empty all write jobs - this.batch.mode = 'writing'; - this.flush(this.batch.write); + // Set the mode to 'writing' + // then empty all write jobs + this.batch.mode = 'writing'; + this.flush(this.batch.write); - this.batch.mode = null; + this.batch.mode = null; + + } catch (e) { + this.runBatch(); + throw e; + } }; /** |