Skip to content

Instantly share code, notes, and snippets.

@williammalo
Forked from 140bytes/LICENSE.txt
Last active October 2, 2015 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save williammalo/2188750 to your computer and use it in GitHub Desktop.
Save williammalo/2188750 to your computer and use it in GitHub Desktop.
vendorPrefixr

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>
@Evghenusi
Copy link

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} ?

@williammalo
Copy link
Author

@Evghenusi

Smart!
I updated my code to match yours!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment