Skip to content

Instantly share code, notes, and snippets.

@wintercounter
Created August 30, 2014 18:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wintercounter/49863501f5085e0c3300 to your computer and use it in GitHub Desktop.
Save wintercounter/49863501f5085e0c3300 to your computer and use it in GitHub Desktop.
MutationObserver Polyfill
(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);
@ndvbd
Copy link

ndvbd commented Jun 30, 2021

Note that nothing is being done with the parameter 'options'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment