Created
November 8, 2011 22:36
-
-
Save ngryman/1349521 to your computer and use it in GitHub Desktop.
Vendor prefix 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
(function() { | |
// Following spec is to expose vendor-specific style properties as: | |
// elem.style.WebkitBorderRadius | |
// and the following would be incorrect: | |
// elem.style.webkitBorderRadius | |
// Webkit ghosts their properties in lowercase but Opera & Moz do not. | |
// Microsoft foregoes prefixes entirely <= IE8, but appears to | |
// use a lowercase `ms` instead of the correct `Ms` in IE9 | |
// More here: http://github.com/Modernizr/Modernizr/issues/issue/21 | |
var domPrefixes = ['Webkit', 'Moz', 'O', 'ms', 'Khtml'], | |
style = document.createElement('div').style, | |
pref; | |
function getProp(prop) { | |
var upperProp = prop.charAt(0).toUpperCase() + prop.slice(1); | |
if (pref === undefined) { | |
pref = null; | |
for (var i = 0, len = domPrefixes.length; i < len; i++) { | |
if ((domPrefixes[i] + upperProp) in style) { | |
pref = domPrefixes[i]; | |
break; | |
} | |
} | |
} | |
if (prop in style) | |
return prop; | |
return pref ? pref + upperProp : undefined; | |
} | |
this.caps = { | |
transition: getProp('transition'), | |
transitionEnd: getProp('transitionEnd') | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment