Skip to content

Instantly share code, notes, and snippets.

@paulirish
Created September 26, 2010 15:12
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulirish/598008 to your computer and use it in GitHub Desktop.
Save paulirish/598008 to your computer and use it in GitHub Desktop.
Modernizr lite - broken and deprecated. SEE COMMENT
// Modernizr lite, unofficial. ;)
// usage:
//
// testStyle('box-shadow')
//
// a class of `boxshadow` or `no-boxshadow` is added to the <html> element accordingly.
function testStyle(style){
var elem = document.createElement('div'),
prefixes = ['Webkit', 'Moz', 'O', 'ms', 'Khtml'],
bool,
bump = function(all, letter) {
return letter.toUpperCase();
},
prop;
// test unprefixed first
bool = style in elem.style;
prop = style.replace(/^(.)/, bump).replace(/-([a-z])/ig, bump);
for (var len = prefixes.length; len--; ){
if (bool) break;
bool = prefixes[len] + prop in elem.style;
}
document.documentElement.className += ' ' + (bool ? '' : 'no-') + style.replace(/-/g,'');
return bool;
};
// degeneralized css3 feature test
// doesnt do string manip so its a lot shorter.
// also just the test and no classes are added.
function testBackgroundClip(){
var div = document.createElement('div');
if ('backgroundClip' in div.style) return true;
'Webkit Moz O ms Khtml'.replace(/([A-Za-z]*)/g,function(val){
if (val+'BackgroundClip' in div.style) return true;
});
};
@paulirish
Copy link
Author

jeff way rewrote this into something that might be better maybe http://snipplr.com/view/44079/test-css3-support-with-js/

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