Skip to content

Commit

Permalink
@font-face callback fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Sep 25, 2009
1 parent 0264e8e commit c424995
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions modernizr.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ window.Modernizr = (function(){
// Create variables for dedicated @font-face test
var st = doc.createElement('style'),
spn = doc.createElement('span'),
wid, nwid, isFakeBody = false, body = doc.body, fontret,
wid, nwid, isFakeBody = false, body = doc.body,
callback, isCallbackCalled;

// The following is a font-face + glyph definition for the . character:
Expand Down Expand Up @@ -383,18 +383,18 @@ window.Modernizr = (function(){

var delayedCheck = function(){
fontret = Modernizr[fontface] = wid !== spn.offsetWidth;
docElement.className = docElement.className.replace(/(no-)?font.*?\b/,'') + fontret ? ' ' : ' no-' + fontface;
docElement.className = docElement.className.replace(/(no-)?font.*?\b/,'') + (fontret ? ' ' : ' no-') + fontface;

callback && (isCallbackCalled = true) && callback(fontret);
isFakeBody && setTimeout(function(){body.parentNode.removeChild(body)},50);
}

setTimeout(delayedCheck,fontfaceCheckDelay);
// allow for a callback
ret._fontfaceready = function(fn){
isCallbackCalled || fontret ? fn(fontret) : (callback = fn);
}
}

// allow for a callback
ret._fontfaceready = function(fn){
(isCallbackCalled || fontret) ? fn(fontret) : (callback = fn);
}

return function(){ return fontret || wid !== spn.offsetWidth; };
Expand Down Expand Up @@ -463,4 +463,4 @@ window.Modernizr = (function(){

return ret;

})();
})();

0 comments on commit c424995

Please sign in to comment.