From 9c843e52f7913cff9529ea0950acc0fbb78f7baa Mon Sep 17 00:00:00 2001 From: Oliver Joseph Ash Date: Fri, 25 Apr 2014 12:04:19 +0100 Subject: [PATCH] =?UTF-8?q?Wrap=20`MutationObserver`=20callback=20in=20`tr?= =?UTF-8?q?y=20=E2=80=A6=20finally`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dom-observer.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/dom-observer.js b/src/dom-observer.js index 63bf219f..0282e0d9 100644 --- a/src/dom-observer.js +++ b/src/dom-observer.js @@ -36,13 +36,15 @@ define([ if (! runningPostMutation && includeRealMutations(mutations)) { runningPostMutation = true; - callback(); - - // We must yield to let any mutation we caused be triggered - // in the next cycle - setTimeout(function() { - runningPostMutation = false; - }, 0); + try { + callback(); + } finally { + // We must yield to let any mutation we caused be triggered + // in the next cycle + setTimeout(function() { + runningPostMutation = false; + }, 0); + } } });