-
-
Save Integralist/6018869 to your computer and use it in GitHub Desktop.
JavaScript function that lets you query for the API or provide a fallback if not available
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
function findOrFallback(where, what, fallback) { | |
for(var | |
vendors = ['', 'webkit', 'moz', 'ms', 'o'], | |
first = what.charAt(0), | |
others = first.toUpperCase(), | |
suffix = what.slice(1), | |
i = 0, length = vendors.length, | |
current; | |
i < length; i++ | |
) { | |
current = where[vendors[i] + (i ? others : first) + suffix]; | |
if (current) return current; | |
} | |
return fallback; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment