Skip to content

Instantly share code, notes, and snippets.

@GCheung55
Forked from divoxx/gist:73976
Created March 4, 2009 20:31
Show Gist options
  • Save GCheung55/73988 to your computer and use it in GitHub Desktop.
Save GCheung55/73988 to your computer and use it in GitHub Desktop.
dispatch some method everytime a dom change
var reapplyTimeoutId = null
$each(['insertBefore', 'replaceChild', 'removeChild', 'appendChild'], function(methodName) {
Node.prototype["_" + methodName] = Node.prototype[methodName]
Node.prototype[methodName] = function() {
var ret = this["_" + methodName](arguments[0], arguments[1])
if (reapplyTimeoutId) { clearTimeout(reapplyTimeoutId) }
reapplyTimeoutId = setTimeout(Attitude.applyDefinitions.bind(Attitude), 100)
return ret
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment