Created
August 30, 2014 18:28
-
-
Save wintercounter/49863501f5085e0c3300 to your computer and use it in GitHub Desktop.
MutationObserver Polyfill
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var MutationObserver; | |
if (window.MutationObserver != null) { | |
return; | |
} | |
MutationObserver = (function() { | |
function MutationObserver(callBack) { | |
this.callBack = callBack; | |
} | |
MutationObserver.prototype.observe = function(element, options) { | |
this.element = element; | |
return this.interval = setInterval((function(_this) { | |
return function() { | |
var html; | |
html = _this.element.innerHTML; | |
if (html !== _this.oldHtml) { | |
_this.oldHtml = html; | |
return _this.callBack.apply(null); | |
} | |
}; | |
})(this), 200); | |
}; | |
MutationObserver.prototype.disconnect = function() { | |
return window.clearInterval(this.interval); | |
}; | |
return MutationObserver; | |
})(); | |
window.MutationObserver = MutationObserver; | |
}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that nothing is being done with the parameter 'options'