Skip to content

Commit

Permalink
Move fontface test to feature-detects/css-fontface.js
Browse files Browse the repository at this point in the history
  • Loading branch information
seutje committed Sep 21, 2012
1 parent 32a5d2b commit e848278
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
20 changes: 20 additions & 0 deletions feature-detects/css-fontface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

// @font-face detection routine by Diego Perini
// javascript.nwbox.com/CSSSupport/

// false positives:
// WebOS github.com/Modernizr/Modernizr/issues/342
// WP7 github.com/Modernizr/Modernizr/issues/538
Modernizr.addTest('fontface', function() {
var bool;

Modernizr.testStyles('@font-face {font-family:"font";src:url("https://")}', function( node, rule ) {
var style = document.getElementById('smodernizr'),
sheet = style.sheet || style.styleSheet,
cssText = sheet ? (sheet.cssRules && sheet.cssRules[0] ? sheet.cssRules[0].cssText : sheet.cssText || '') : '';

bool = /src/i.test(cssText) && cssText.indexOf(rule.split(' ')[0]) === 0;
});

return bool;
});
23 changes: 0 additions & 23 deletions modernizr.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,29 +554,6 @@ window.Modernizr = (function( window, document, undefined ) {
};


/*>>fontface*/
// @font-face detection routine by Diego Perini
// javascript.nwbox.com/CSSSupport/

// false positives:
// WebOS github.com/Modernizr/Modernizr/issues/342
// WP7 github.com/Modernizr/Modernizr/issues/538
tests['fontface'] = function() {
var bool;

injectElementWithStyles('@font-face {font-family:"font";src:url("https://")}', function( node, rule ) {
var style = document.getElementById('smodernizr'),
sheet = style.sheet || style.styleSheet,
cssText = sheet ? (sheet.cssRules && sheet.cssRules[0] ? sheet.cssRules[0].cssText : sheet.cssText || '') : '';

bool = /src/i.test(cssText) && cssText.indexOf(rule.split(' ')[0]) === 0;
});

return bool;
};
/*>>fontface*/


/*>>webforms*/
// input features and input types go directly onto the ret object, bypassing the tests loop.
// Hold this guy to execute in a moment.
Expand Down

0 comments on commit e848278

Please sign in to comment.