Skip to content

Instantly share code, notes, and snippets.

@williammalo williammalo/README.md forked from 140bytes/LICENSE.txt
Last active Oct 2, 2015

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

commented Mar 25, 2012

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

This comment has been minimized.

Copy link
Owner Author

commented Mar 25, 2012

@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
You can’t perform that action at this time.