webfontloader 1.6.8 → 1.6.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4164b541b5770878b3fd7fbb3c79f7450649891c
4
- data.tar.gz: c716c510446e57990b3c0c07f4741b1e170ca892
3
+ metadata.gz: d8594aa7b6469c3d2cc133e3a1a07bdfc66dccdc
4
+ data.tar.gz: 753162efa8e0c0dec8a57659adab08b664967d80
5
5
  SHA512:
6
- metadata.gz: a93f51b5e24eab7f7cf44a43ff1bb6047c36189c2d7e13591b0b8b59aa4134138b2d449cb4ea9524f3e04555e7722dba72fa947115715d94b7bfd6503ba6607b
7
- data.tar.gz: 4f346002717ddb89d7e3ce98208b459ee5133fa5d408c643f66c7d10524ea1f1a5584aaeb4bdd27efeb16d9201782a1f17f2ccc0d71efab7a76b97aaace4e605
6
+ metadata.gz: 97a724af7078ac83e6bcc2553ae113addb3bbe95e620dc6f7f081ee6b4dd2db53be4db475ee8da03d637516d16fafe0167eea0a9396fe428813dc7ca2c1c2a46
7
+ data.tar.gz: 34b16e105775ff9f29ae76e7976b3e175c6bb3ab4ff61f4770dab6b71df420e0448bfd1fe763ed6edd0d030c6d2a0303188dfe2962c8ceffb3694fd6ac1d181e
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ v1.6.9 (October 9, 2015)
2
+
3
+ * Fix native font load detection when combined with asynchronous CSS loading
4
+ * Fix support for font family names starting with a number
5
+
1
6
  v1.6.8 (October 1, 2015)
2
7
 
3
8
  * Add support for the native font loading API.
data/lib/webfontloader.rb CHANGED
@@ -3,7 +3,7 @@ require 'yaml'
3
3
  require 'webfontloader/modules'
4
4
 
5
5
  module WebFontLoader
6
- VERSION = '1.6.8'
6
+ VERSION = '1.6.9'
7
7
 
8
8
  ProjectRoot = File.expand_path(File.dirname(__FILE__) + "/..")
9
9
 
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webfontloader",
3
- "version": "1.6.7",
3
+ "version": "1.6.8",
4
4
  "description": "Web Font Loader gives you added control when using linked fonts via @font-face.",
5
5
  "main": "webfontloader.js",
6
6
  "scripts": {
@@ -280,6 +280,60 @@ describe('DomHelper', function () {
280
280
  });
281
281
  });
282
282
 
283
+ describe('#loadStylesheet with callback', function () {
284
+ it('should load the stylesheet', function () {
285
+ var el = null,
286
+ width = null,
287
+ callbackMade = false;
288
+
289
+ function callback() {
290
+ callbackMade = true;
291
+ }
292
+
293
+ runs(function () {
294
+ el = domHelper.createElement('div', { id: 'TEST_ELEMENT' });
295
+ domHelper.insertInto('body', el);
296
+ width = el.offsetWidth;
297
+ domHelper.loadStylesheet('fixtures/external_stylesheet.css', callback);
298
+ });
299
+
300
+ waitsFor(function () {
301
+ return callbackMade;
302
+ });
303
+
304
+ runs(function () {
305
+ expect(el.offsetWidth).toEqual(300);
306
+ });
307
+ });
308
+ });
309
+
310
+ describe('#loadStylesheet with async and callback', function () {
311
+ it('should load the stylesheet', function () {
312
+ var el = null,
313
+ width = null,
314
+ callbackMade = false;
315
+
316
+ function callback() {
317
+ callbackMade = true;
318
+ }
319
+
320
+ runs(function () {
321
+ el = domHelper.createElement('div', { id: 'TEST_ELEMENT' });
322
+ domHelper.insertInto('body', el);
323
+ width = el.offsetWidth;
324
+ domHelper.loadStylesheet('fixtures/external_stylesheet.css', callback, true);
325
+ });
326
+
327
+ waitsFor(function () {
328
+ return callbackMade;
329
+ });
330
+
331
+ runs(function () {
332
+ expect(el.offsetWidth).toEqual(300);
333
+ });
334
+ });
335
+ });
336
+
283
337
  describe('#loadScript', function () {
284
338
  it('should load the script', function () {
285
339
  runs(function () {
@@ -306,36 +306,34 @@ goog.scope(function () {
306
306
  'media': (opt_async ? 'only x' : 'all')
307
307
  });
308
308
 
309
- var sheets = this.document_.styleSheets;
310
-
311
- var done = false;
309
+ var sheets = this.document_.styleSheets,
310
+ eventFired = false,
311
+ asyncResolved = !opt_async,
312
+ callbackArg = null;
313
+
314
+ function mayInvokeCallback() {
315
+ if (opt_callback && eventFired && asyncResolved) {
316
+ opt_callback(callbackArg);
317
+ opt_callback = null;
318
+ }
319
+ }
312
320
 
313
321
  if (DomHelper.CAN_WAIT_STYLESHEET) {
314
322
  link.onload = function () {
315
- if (!done) {
316
- done = true;
317
-
318
- if (opt_callback) {
319
- opt_callback(null);
320
- }
321
- }
323
+ eventFired = true;
324
+ mayInvokeCallback();
322
325
  };
323
326
 
324
327
  link.onerror = function () {
325
- if (!done) {
326
- done = true;
327
-
328
- if (opt_callback) {
329
- opt_callback(new Error('Stylesheet failed to load'));
330
- }
331
- }
328
+ eventFired = true;
329
+ callbackArg = new Error('Stylesheet failed to load');
330
+ mayInvokeCallback();
332
331
  };
333
332
  } else {
334
333
  // Some callers expect opt_callback being called asynchronously.
335
334
  setTimeout(function () {
336
- if (opt_callback) {
337
- opt_callback(null);
338
- }
335
+ eventFired = true;
336
+ mayInvokeCallback();
339
337
  }, 0);
340
338
  }
341
339
 
@@ -356,6 +354,11 @@ goog.scope(function () {
356
354
  if (opt_async) {
357
355
  onAvailable(function () {
358
356
  link.media = "all";
357
+ // Give another tick to ensure the @media change takes effect.
358
+ setTimeout(function() {
359
+ asyncResolved = true;
360
+ mayInvokeCallback();
361
+ }, 0);
359
362
  });
360
363
  }
361
364
 
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'webfontloader'
16
- s.version = '1.6.8'
17
- s.date = '2015-10-01'
16
+ s.version = '1.6.9'
17
+ s.date = '2015-10-09'
18
18
 
19
19
  ## Make sure your summary is short. The description may be as long
20
20
  ## as you like.
data/webfontloader.js CHANGED
@@ -1,7 +1,7 @@
1
- /* Web Font Loader v1.6.8 - (c) Adobe Systems, Google. License: Apache 2.0 */
1
+ /* Web Font Loader v1.6.9 - (c) Adobe Systems, Google. License: Apache 2.0 */
2
2
  (function(){function aa(a,b,c){return a.call.apply(a.bind,arguments)}function ba(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}}function n(a,b,c){n=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?aa:ba;return n.apply(null,arguments)}var p=Date.now||function(){return+new Date};function q(a,b){this.F=a;this.k=b||a;this.H=this.k.document}var ca=!!window.FontFace;q.prototype.createElement=function(a,b,c){a=this.H.createElement(a);if(b)for(var d in b)b.hasOwnProperty(d)&&("style"==d?a.style.cssText=b[d]:a.setAttribute(d,b[d]));c&&a.appendChild(this.H.createTextNode(c));return a};function s(a,b,c){a=a.H.getElementsByTagName(b)[0];a||(a=document.documentElement);a.insertBefore(c,a.lastChild)}
3
3
  function t(a,b,c){b=b||[];c=c||[];for(var d=a.className.split(/\s+/),e=0;e<b.length;e+=1){for(var f=!1,g=0;g<d.length;g+=1)if(b[e]===d[g]){f=!0;break}f||d.push(b[e])}b=[];for(e=0;e<d.length;e+=1){f=!1;for(g=0;g<c.length;g+=1)if(d[e]===c[g]){f=!0;break}f||b.push(d[e])}a.className=b.join(" ").replace(/\s+/g," ").replace(/^\s+|\s+$/,"")}function u(a,b){for(var c=a.className.split(/\s+/),d=0,e=c.length;d<e;d++)if(c[d]==b)return!0;return!1}
4
- function v(a){if("string"===typeof a.fa)return a.fa;var b=a.k.location.protocol;"about:"==b&&(b=a.F.location.protocol);return"https:"==b?"https:":"http:"}function x(a,b,c){b=a.createElement("link",{rel:"stylesheet",href:b,media:"all"});var d=!1;ca?(b.onload=function(){d||(d=!0,c&&c(null))},b.onerror=function(){d||(d=!0,c&&c(Error("Stylesheet failed to load")))}):setTimeout(function(){c&&c(null)},0);s(a,"head",b)}
4
+ function v(a){if("string"===typeof a.fa)return a.fa;var b=a.k.location.protocol;"about:"==b&&(b=a.F.location.protocol);return"https:"==b?"https:":"http:"}function x(a,b,c){function d(){c&&e&&f&&(c(g),c=null)}b=a.createElement("link",{rel:"stylesheet",href:b,media:"all"});var e=!1,f=!0,g=null;ca?(b.onload=function(){e=!0;d()},b.onerror=function(){e=!0;g=Error("Stylesheet failed to load");d()}):setTimeout(function(){e=!0;d()},0);s(a,"head",b)}
5
5
  function y(a,b,c,d){var e=a.H.getElementsByTagName("head")[0];if(e){var f=a.createElement("script",{src:b}),g=!1;f.onload=f.onreadystatechange=function(){g||this.readyState&&"loaded"!=this.readyState&&"complete"!=this.readyState||(g=!0,c&&c(null),f.onload=f.onreadystatechange=null,"HEAD"==f.parentNode.tagName&&e.removeChild(f))};e.appendChild(f);setTimeout(function(){g||(g=!0,c&&c(Error("Script load timeout")))},d||5E3);return f}return null};function z(){this.S=0;this.K=null}function A(a){a.S++;return function(){a.S--;B(a)}}function C(a,b){a.K=b;B(a)}function B(a){0==a.S&&a.K&&(a.K(),a.K=null)};function D(a){this.ea=a||"-"}D.prototype.d=function(a){for(var b=[],c=0;c<arguments.length;c++)b.push(arguments[c].replace(/[\W_]+/g,"").toLowerCase());return b.join(this.ea)};function E(a,b){this.Q=a;this.M=4;this.L="n";var c=(b||"n4").match(/^([nio])([1-9])$/i);c&&(this.L=c[1],this.M=parseInt(c[2],10))}E.prototype.getName=function(){return this.Q};function da(a){return G(a)+" "+(a.M+"00")+" 300px "+H(a.Q)}function H(a){var b=[];a=a.split(/,\s*/);for(var c=0;c<a.length;c++){var d=a[c].replace(/['"]/g,"");-1==d.indexOf(" ")?b.push(d):b.push("'"+d+"'")}return b.join(",")}function I(a){return a.L+a.M}
6
6
  function G(a){var b="normal";"o"===a.L?b="oblique":"i"===a.L&&(b="italic");return b}function ea(a){var b=4,c="n",d=null;a&&((d=a.match(/(normal|oblique|italic)/i))&&d[1]&&(c=d[1].substr(0,1).toLowerCase()),(d=a.match(/([1-9]00|normal|bold)/i))&&d[1]&&(/bold/i.test(d[1])?b=7:/[1-9]00/.test(d[1])&&(b=parseInt(d[1].substr(0,1),10))));return c+b};function fa(a,b){this.a=a;this.j=a.k.document.documentElement;this.O=b;this.g="wf";this.e=new D("-");this.da=!1!==b.events;this.u=!1!==b.classes}function ga(a){a.u&&t(a.j,[a.e.d(a.g,"loading")]);J(a,"loading")}function K(a){if(a.u){var b=u(a.j,a.e.d(a.g,"active")),c=[],d=[a.e.d(a.g,"loading")];b||c.push(a.e.d(a.g,"inactive"));t(a.j,c,d)}J(a,"inactive")}function J(a,b,c){if(a.da&&a.O[b])if(c)a.O[b](c.getName(),I(c));else a.O[b]()};function ha(){this.t={}}function ia(a,b,c){var d=[],e;for(e in b)if(b.hasOwnProperty(e)){var f=a.t[e];f&&d.push(f(b[e],c))}return d};function L(a,b){this.a=a;this.h=b;this.m=this.a.createElement("span",{"aria-hidden":"true"},this.h)}function M(a,b){var c=a.m,d;d="display:block;position:absolute;top:-9999px;left:-9999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;white-space:nowrap;font-family:"+H(b.Q)+";"+("font-style:"+G(b)+";font-weight:"+(b.M+"00")+";");c.style.cssText=d}function N(a){s(a.a,"body",a.m)}L.prototype.remove=function(){var a=this.m;a.parentNode&&a.parentNode.removeChild(a)};function O(a,b,c,d,e,f){this.G=a;this.J=b;this.f=d;this.a=c;this.v=e||3E3;this.h=f||void 0}O.prototype.start=function(){var a=this.a.k.document,b=this;Promise.race([new Promise(function(a,d){setTimeout(function(){d(b.f)},b.v)}),a.fonts.load(da(this.f),this.h)]).then(function(a){1===a.length?b.G(b.f):b.J(b.f)},function(){b.J(b.f)})};function P(a,b,c,d,e,f,g){this.G=a;this.J=b;this.a=c;this.f=d;this.h=g||"BESbswy";this.s={};this.v=e||3E3;this.Z=f||null;this.D=this.C=this.A=this.w=null;this.w=new L(this.a,this.h);this.A=new L(this.a,this.h);this.C=new L(this.a,this.h);this.D=new L(this.a,this.h);M(this.w,new E(this.f.getName()+",serif",I(this.f)));M(this.A,new E(this.f.getName()+",sans-serif",I(this.f)));M(this.C,new E("serif",I(this.f)));M(this.D,new E("sans-serif",I(this.f)));N(this.w);N(this.A);N(this.C);N(this.D)}
7
7
  var Q={ia:"serif",ha:"sans-serif"},R=null;function S(){if(null===R){var a=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);R=!!a&&(536>parseInt(a[1],10)||536===parseInt(a[1],10)&&11>=parseInt(a[2],10))}return R}P.prototype.start=function(){this.s.serif=this.C.m.offsetWidth;this.s["sans-serif"]=this.D.m.offsetWidth;this.ga=p();T(this)};function ja(a,b,c){for(var d in Q)if(Q.hasOwnProperty(d)&&b===a.s[Q[d]]&&c===a.s[Q[d]])return!0;return!1}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webfontloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.8
4
+ version: 1.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Carver
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-10-01 00:00:00.000000000 Z
12
+ date: 2015-10-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake