modernizr
Version:
Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.
32 lines (30 loc) • 857 B
JavaScript
/*!
{
"name": "CSS Font rem Units",
"caniuse": "rem",
"authors": ["nsfmc"],
"property": "cssremunit",
"tags": ["css"],
"builderAliases": ["css_remunit"],
"notes": [{
"name": "W3C Spec",
"href": "https://www.w3.org/TR/css3-values/#relative0"
},{
"name": "Font Size with rem by Jonathan Snook",
"href": "http://snook.ca/archives/html_and_css/font-size-with-rem"
}]
}
!*/
define(['Modernizr', 'createElement'], function(Modernizr, createElement) {
// "The 'rem' unit ('root em') is relative to the computed
// value of the 'font-size' value of the root element."
// you can test by checking if the prop was ditched
Modernizr.addTest('cssremunit', function() {
var style = createElement('a').style;
try {
style.fontSize = '3rem';
}
catch (e) {}
return (/rem/).test(style.fontSize);
});
});