Skip to content

Instantly share code, notes, and snippets.

@kajyr
Last active August 29, 2015 14:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kajyr/c806965e5781b754d8e9 to your computer and use it in GitHub Desktop.
Save kajyr/c806965e5781b754d8e9 to your computer and use it in GitHub Desktop.
A small polyfill to handle mutation observer subtree modifications events
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