Created
September 26, 2010 15:12
-
-
Save paulirish/598008 to your computer and use it in GitHub Desktop.
Modernizr lite - broken and deprecated. SEE COMMENT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
jeff way rewrote this into something that might be better maybe http://snipplr.com/view/44079/test-css3-support-with-js/