Created
March 24, 2013 09:36
-
-
Save stucox/5231211 to your computer and use it in GitHub Desktop.
Mutation Observer feature detection
This file contains 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
// http://www.w3.org/TR/dom/ | |
// http://updates.html5rocks.com/2012/02/Detect-DOM-changes-with-Mutation-Observers | |
// https://developer.mozilla.org/en-US/docs/DOM/MutationObserver | |
var MutationObserver = (function () { | |
var prefixes = ['WebKit', 'Moz', 'O', 'Ms', ''] | |
for(var i=0; i < prefixes.length; i++) { | |
if(prefixes[i] + 'MutationObserver' in window) { | |
return window[prefixes[i] + 'MutationObserver']; | |
} | |
} | |
return false; | |
}()); | |
if(MutationObserver) { | |
// Use MutationObserver | |
} | |
else { | |
// Fallback | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment