Skip to content

Instantly share code, notes, and snippets.

@disnet
Created July 22, 2013 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save disnet/6055864 to your computer and use it in GitHub Desktop.
Save disnet/6055864 to your computer and use it in GitHub Desktop.
macro forThing {
case $val ($a:expr, $b:expr) => {(function($val){forEach.call($b, this)}).bind($a)}
case $val ($a:expr) => {(function($val){forEach.call(val,this)}).bind($a)}
}
function makeMutationObserver(tag){
var queue= tag.queue,
put= queue.put.bind(queue),
mutationAddObserve= forThing val (put, val.getElementsByTagName(this.tag)),
mutationObserver= forThing val (mutationAddObserve, val.addedNodes),
mutationsObserver= forThing val (mutationObserver)
return new MutationObserver(mutationsObserver)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment