UNPKG

modernizr

Version:

Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.

27 lines (25 loc) 942 B
/*! { "name": "@font-face", "property": "fontface", "authors": ["Diego Perini"], "tags": ["css"], "knownBugs": [ "False Positive: WebOS http://github.com/Modernizr/Modernizr/issues/342", "False Postive: WP7 http://github.com/Modernizr/Modernizr/issues/538" ], "notes": [{ "name": "@font-face detection routine by Diego Perini", "href": "http://javascript.nwbox.com/CSSSupport/" }] } !*/ define(['Modernizr', 'testStyles'], function( Modernizr, testStyles ) { testStyles('@font-face {font-family:"font";src:url("https://")}', function( node, rule ) { var style = document.getElementById('smodernizr'); var sheet = style.sheet || style.styleSheet; var cssText = sheet ? (sheet.cssRules && sheet.cssRules[0] ? sheet.cssRules[0].cssText : sheet.cssText || '') : ''; var bool = /src/i.test(cssText) && cssText.indexOf(rule.split(' ')[0]) === 0; Modernizr.addTest('fontface', bool); }); });