Created
February 19, 2012 02:49
-
-
Save allex/1861719 to your computer and use it in GitHub Desktop.
Get vendor style prefix
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
/* vim: set ft=javascript */ | |
// http://addyosmani.com/polyfillthehtml5gaps/slides/#78 | |
function getPrefix(prop){ | |
var prefixes = ['Moz','Khtml','Webkit','O','ms'], | |
elem = document.createElement('div'), | |
upper = prop.charAt(0).toUpperCase() + prop.slice(1); | |
if (prop in elem.style) | |
return prop; | |
for (var len = prefixes.length; len--; ){ | |
if ((prefixes[len] + upper) in elem.style) | |
return (prefixes[len] + upper); | |
} | |
return false; | |
} | |
console.log(getPrefix('transform'));//WebkitTransform |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment