Skip to content
This repository has been archived by the owner on Jun 15, 2021. It is now read-only.

Commit

Permalink
Wrap MutationObserver callback in try … finally
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Joseph Ash committed Apr 25, 2014
1 parent dc1042f commit 9c843e5
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/dom-observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
});

Expand Down

0 comments on commit 9c843e5

Please sign in to comment.