Skip to content

Commit

Permalink
Fix mutation observer implementation for library agnostic code
Browse files Browse the repository at this point in the history
  • Loading branch information
darcyclarke committed Nov 15, 2013
1 parent 28e6d79 commit 374f592
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,18 @@ window.watch = function(){
}

// Set data
if(!this.watching)
this.watching = [];
this.watching.push(data);
if(!that.watching)
that.watching = [];
that.watching.push(data);

// Choose method of watching and fallback
if(MutationObserver){
var observer = new MutationObserver(function(mutations){
mutations.forEach(function(e) {
callback.call(that, e);
callback.call(el, e);
});
});
observer.observe(this, { subtree: false, attributes: true });
observer.observe(el, { subtree: false, attributes: true });
} else if(isEventSupported('DOMAttrModified', div)){
addEvent(el, 'DOMAttrModified', callback);
} else if(isEventSupported('propertychange', div)){
Expand Down
2 changes: 1 addition & 1 deletion watch.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 374f592

Please sign in to comment.