Adds vendor prefix when needed.
Thanks to Evghenusi for minification tips
function( | |
a, //(string) property to vendor-prefixize | |
b,c,d //placeholders | |
) | |
{ | |
for(b in c=["Moz","Webkit","Ms","O"]) //for every prefix | |
if((d=c[b]+ | |
a[0].toUpperCase()+a.slice(1) //capitalize property | |
) in (new Image).style) //check if the prefixed property is an object of (new Image).style | |
a=d; //set variable: a to the prefixed poperty | |
return a //return the prefixed property, else return the unprefixed property | |
} |
function(a,b,c,d){for(b in c=["Moz","Webkit","Ms","O"])if((d=c[b]+a[0].toUpperCase()+a.slice(1))in(new Image).style)a=d;return a} |
{ | |
"name": "vendorPrefixr", | |
"description": "Adds vendor prefix when needed", | |
"keywords": [ | |
"css", | |
"dom", | |
"style", | |
"vendor", | |
"prefix" | |
] | |
} |
<!DOCTYPE html> | |
<script> | |
vendorPrefixr = function(a,b,c,d){for(b in c=["Moz","Webkit","Ms","O"])if((d=c[b]+a[0].toUpperCase()+a.slice(1))in(new Image).style)a=d;return a} | |
document.write(vendorPrefixr("transition")) | |
</script> |
Smart!
I updated my code to match yours!
function(a,b,c,d){for(b in c=["Moz","Webkit","Ms","O"])if((d=c[b]+a[0].toUpperCase()+a.slice(1))in(new Image).style)a=d;return a}
?