Skip to content

Commit

Permalink
Merge pull request #94 from dfilatov/use-mutation-observer
Browse files Browse the repository at this point in the history
Use MutationObserver if possible
  • Loading branch information
dfilatov committed Jun 11, 2015
2 parents c963ef9 + 25d5896 commit 213f20d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/vow.js
Expand Up @@ -36,7 +36,19 @@ var undef,
};
}

if(global.postMessage) { // modern browsers
var MutationObserver = global.MutationObserver || global.WebKitMutationObserver; // modern browsers
if(MutationObserver) {
var num = 1,
node = document.createTextNode('');

new MutationObserver(callFns).observe(node, { characterData : true });

return function(fn) {
enqueueFn(fn) && (node.data = (num *= -1));
};
}

if(global.postMessage) {
var isPostMessageAsync = true;
if(global.attachEvent) {
var checkAsync = function() {
Expand Down

0 comments on commit 213f20d

Please sign in to comment.