Last active
August 29, 2015 14:01
-
-
Save kajyr/c806965e5781b754d8e9 to your computer and use it in GitHub Desktop.
A small polyfill to handle mutation observer subtree modifications events
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
return if window.MutationObserver? | |
class MutationObserver | |
constructor: (callBack) -> | |
@callBack = callBack | |
observe: (element, options) -> | |
@element = element | |
@interval = setInterval () => | |
html = @element.innerHTML | |
if html != @oldHtml | |
@oldHtml = html | |
@callBack.apply(null) | |
, 200 | |
, | |
disconnect: () -> | |
window.clearInterval(@interval) | |
window.MutationObserver = MutationObserver |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment