modernizr
Version:
Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.
26 lines (23 loc) • 876 B
JavaScript
/*!
{
"name": "CSS Opacity",
"caniuse": "css-opacity",
"property": "opacity",
"tags": ["css"],
"notes": ["Opacity must be be in the range of [0.0,1.0], according to the spec."]
}
!*/
define(['Modernizr', 'createElement', 'prefixes'], function( Modernizr, createElement, prefixes ) {
// Browsers that actually have CSS Opacity implemented have done so
// according to spec, which means their return values are within the
// range of [0.0,1.0] - including the leading zero.
Modernizr.addTest('opacity', function() {
var elem = createElement('div');
var style = elem.style;
style.cssText = prefixes.join('opacity:.55;');
// The non-literal . in this regex is intentional:
// German Chrome returns this value as 0,55
// github.com/Modernizr/Modernizr/issues/#issue/59/comment/516632
return (/^0.55$/).test(style.opacity);
});
});