Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes an issue where we were starting to check for the font before th…

…e link was inserted on IE when waiting for the body to be present.
  • Loading branch information...
commit 1f355b7efb6be512da04af965cf45d73f1c824a7 1 parent 60cd6a3
@jeremiele jeremiele authored
Showing with 17 additions and 13 deletions.
  1. +3 −1 src/core/fontwatcher.js
  2. +14 −12 src/google/googlefontapi.js
View
4 src/core/fontwatcher.js
@@ -31,7 +31,9 @@ webfont.FontWatcher.DEFAULT_VARIATION = 'n4';
* Watches a set of font families.
* @param {Array.<string>} fontFamilies The font family names to watch.
* @param {Object.<string, Array.<string>>} fontDescriptions The font variations
- * of each family to watch. Described with FVD.
+ * of each family to watch. Described with FVD.
+ * @param {Object.<string, string>} fontTestStrings The font test strings for
+ * each family.
* @param {boolean} last True if this is the last set of families to watch.
*/
webfont.FontWatcher.prototype.watch = function(fontFamilies, fontDescriptions,
View
26 src/google/googlefontapi.js
@@ -17,27 +17,29 @@ webfont.GoogleFontApi.prototype.supportUserAgent = function(userAgent, support)
};
webfont.GoogleFontApi.prototype.load = function(onReady) {
- var fontApiUrlBuilder = new webfont.FontApiUrlBuilder(
- this.configuration_['api']);
- var fontFamilies = this.configuration_['families'];
var domHelper = this.domHelper_;
var nonBlockingIe = this.userAgent_.getName() == 'MSIE' &&
this.configuration_['blocking'] != true;
- fontApiUrlBuilder.setFontFamilies(fontFamilies);
-
if (nonBlockingIe) {
- domHelper.whenBodyExists(function() {
- domHelper.insertInto('head', domHelper.createCssLink(
- fontApiUrlBuilder.build()));
- });
+ domHelper.whenBodyExists(webfont.bind(this, this.insertLink_, onReady));
} else {
- domHelper.insertInto('head', domHelper.createCssLink(
- fontApiUrlBuilder.build()));
+ this.insertLink_(onReady);
}
- var fontApiParser = new webfont.FontApiParser(fontFamilies);
+};
+webfont.GoogleFontApi.prototype.insertLink_ = function(onReady) {
+ var domHelper = this.domHelper_;
+ var fontApiUrlBuilder = new webfont.FontApiUrlBuilder(
+ this.configuration_['api']);
+ var fontFamilies = this.configuration_['families'];
+ fontApiUrlBuilder.setFontFamilies(fontFamilies);
+
+ var fontApiParser = new webfont.FontApiParser(fontFamilies);
fontApiParser.parse();
+
+ domHelper.insertInto('head', domHelper.createCssLink(
+ fontApiUrlBuilder.build()));
onReady(fontApiParser.getFontFamilies(), fontApiParser.getVariations(),
fontApiParser.getFontTestStrings());
};
Please sign in to comment.
Something went wrong with that request. Please try again.