Skip to content

Instantly share code, notes, and snippets.

@Wilto
Created January 13, 2012 18:03
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 Wilto/1607814 to your computer and use it in GitHub Desktop.
Save Wilto/1607814 to your computer and use it in GitHub Desktop.
var vendors = [ "Webkit", "Moz", "O" ];
function validStyle( prop, value, check_vend ) {
var div = document.createElement('div'),
uc = function( txt ) {
return txt.charAt( 0 ).toUpperCase() + txt.substr( 1 )
},
vend_pref = function( vend ) {
return "-" + vend.charAt( 0 ).toLowerCase() + vend.substr( 1 ) + "-";
},
check_style = function( vend ) {
var vend_prop = vend_pref( vend ) + prop + ": " + value + ";",
uc_vend = uc( vend ),
propStyle = uc_vend + uc( prop );
div.setAttribute( "style", vend_prop );
if( !!div.style[ propStyle ] ) {
ret = true;
}
},
check_vends = check_vend ? [ check_vend ] : vendors,
ret;
for( i = 0; i < check_vends.length; i++ ) {
check_style( check_vends[i] );
}
return !!ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment