Socket
Socket
Sign inDemoInstall

fontfaceobserver

Package Overview
Dependencies
2
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.8 to 1.4.9

15

fontfaceobserver.js

@@ -1,6 +0,9 @@

(function(){'use strict';function h(a){function b(){document.body?a():setTimeout(b,0)}b()};function v(a){this.a=document.createElement("div");this.a.setAttribute("aria-hidden","true");this.a.appendChild(document.createTextNode(a));this.b=document.createElement("span");this.c=document.createElement("span");this.f=document.createElement("span");this.e=document.createElement("span");this.d=-1;this.b.style.cssText="display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;";this.c.style.cssText="display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;";
this.e.style.cssText="display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;";this.f.style.cssText="display:inline-block;width:200%;height:200%;";this.b.appendChild(this.f);this.c.appendChild(this.e);this.a.appendChild(this.b);this.a.appendChild(this.c)}function w(a,b,c){a.a.style.cssText="min-width:20px;min-height:20px;display:inline-block;position:absolute;width:auto;margin:0;padding:0;top:-999px;left:-999px;white-space:nowrap;font-size:100px;font-family:"+b+";"+c}
function x(a){var b=a.a.offsetWidth,c=b+100;a.e.style.width=c+"px";a.c.scrollLeft=c;a.b.scrollLeft=a.b.scrollWidth+100;return a.d!==b?(a.d=b,!0):!1}function y(a,b){a.b.addEventListener("scroll",function(){x(a)&&null!==a.a.parentNode&&b(a.d)},!1);a.c.addEventListener("scroll",function(){x(a)&&null!==a.a.parentNode&&b(a.d)},!1);x(a)};function z(a,b){var c=b||{};this.family=a;this.style=c.style||"normal";this.variant=c.variant||"normal";this.weight=c.weight||"normal";this.stretch=c.stretch||"stretch";this.featureSettings=c.featureSettings||"normal"}var B=null;
z.prototype.a=function(a,b){var c=a||"BESbswy",C=b||3E3,k="font-style:"+this.style+";font-variant:"+this.variant+";font-weight:"+this.weight+";font-stretch:"+this.stretch+";font-feature-settings:"+this.featureSettings+";-moz-font-feature-settings:"+this.featureSettings+";-webkit-font-feature-settings:"+this.featureSettings+";",g=document.createElement("div"),l=new v(c),m=new v(c),n=new v(c),d=-1,e=-1,f=-1,q=-1,r=-1,t=-1,p=this;return new Promise(function(a,b){function c(){null!==g.parentNode&&g.parentNode.removeChild(g)}
function u(){if(-1!==d&&-1!==e||-1!==d&&-1!==f||-1!==e&&-1!==f)if(d===e||d===f||e===f){if(null===B){var b=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);B=!!b&&(536>parseInt(b[1],10)||536===parseInt(b[1],10)&&11>=parseInt(b[2],10))}B?d===q&&e===q&&f===q||d===r&&e===r&&f===r||d===t&&e===t&&f===t||(c(),a(p)):(c(),a(p))}}h(function(){function a(){if(Date.now()-D>=C)c(),b(p);else{var A=document.hidden;if(!0===A||void 0===A)d=l.a.offsetWidth,e=m.a.offsetWidth,f=n.a.offsetWidth,
u();setTimeout(a,50)}}var D=Date.now();w(l,"sans-serif",k);w(m,"serif",k);w(n,"monospace",k);g.appendChild(l.a);g.appendChild(m.a);g.appendChild(n.a);document.body.appendChild(g);q=l.a.offsetWidth;r=m.a.offsetWidth;t=n.a.offsetWidth;a();y(l,function(a){d=a;u()});w(l,p.family+",sans-serif",k);y(m,function(a){e=a;u()});w(m,p.family+",serif",k);y(n,function(a){f=a;u()});w(n,p.family+",monospace",k)})})};window.FontFaceObserver=z;window.FontFaceObserver.prototype.check=z.prototype.a;}());
(function(){'use strict';function e(a){function b(){document.body?a():setTimeout(b,0)}b()};function f(a){this.a=document.createElement("div");this.a.setAttribute("aria-hidden","true");this.a.appendChild(document.createTextNode(a));this.b=document.createElement("span");this.c=document.createElement("span");this.f=document.createElement("span");this.e=document.createElement("span");this.d=-1;this.b.style.cssText="display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;";this.c.style.cssText="display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;";
this.e.style.cssText="display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;";this.f.style.cssText="display:inline-block;width:200%;height:200%;";this.b.appendChild(this.f);this.c.appendChild(this.e);this.a.appendChild(this.b);this.a.appendChild(this.c)}function n(a,b,c){a.a.style.cssText="min-width:20px;min-height:20px;display:inline-block;position:absolute;width:auto;margin:0;padding:0;top:-999px;left:-999px;white-space:nowrap;font-size:100px;font-family:"+b+";"+c}
function u(a){var b=a.a.offsetWidth,c=b+100;a.e.style.width=c+"px";a.c.scrollLeft=c;a.b.scrollLeft=a.b.scrollWidth+100;return a.d!==b?(a.d=b,!0):!1}function z(a,b){a.b.addEventListener("scroll",function(){u(a)&&null!==a.a.parentNode&&b(a.d)},!1);a.c.addEventListener("scroll",function(){u(a)&&null!==a.a.parentNode&&b(a.d)},!1);u(a)};function A(a){this.a=B;this.b=void 0;this.c=[];var b=this;try{a(function(a){b.resolve(a)},function(a){b.reject(a)})}catch(c){b.reject(c)}}var B=2;A.prototype.resolve=function(a){var b=this;if(b.a===B){if(a===b)throw new TypeError("Promise settled with itself.");var c=!1;try{var g=a&&a.then;if(null!==a&&"object"===typeof a&&"function"===typeof g){g.call(a,function(a){c||b.resolve(a);c=!0},function(a){c||b.reject(a);c=!0});return}}catch(d){c||b.reject(d);return}b.a=0;b.b=a;C(b)}};
A.prototype.reject=function(a){if(this.a===B){if(a===this)throw new TypeError("Promise settled with itself.");this.a=1;this.b=a;C(this)}};function C(a){setTimeout(function(){if(a.a!==B)for(;a.c.length;){var b=a.c.shift(),c=b[0],g=b[1],d=b[2],b=b[3];try{0===a.a?"function"===typeof c?d(c.call(void 0,a.b)):d(a.b):1===a.a&&("function"===typeof g?d(g.call(void 0,a.b)):b(a.b))}catch(h){b(h)}}},0)}A.prototype.catch=function(a){return this.then(void 0,a)};
A.prototype.then=function(a,b){var c=this;return new A(function(g,d){c.c.push([a,b,g,d]);C(c)})};
if(window.Promise){var D=window.Promise;D.prototype.then=window.Promise.prototype.then;D.prototype.catch=window.Promise.prototype["catch"];D.all=window.Promise.all;D.race=window.Promise.race;D.resolve=window.Promise.resolve;D.reject=window.Promise.reject}else D=A,D.prototype.then=A.prototype.then,D.prototype.catch=A.prototype.catch,D.all=A.prototype.all,D.race=A.prototype.race,D.resolve=A.prototype.resolve,D.reject=A.prototype.reject;function E(a,b){var c=b||{};this.family=a;this.style=c.style||"normal";this.variant=c.variant||"normal";this.weight=c.weight||"normal";this.stretch=c.stretch||"stretch";this.featureSettings=c.featureSettings||"normal"}var F=null;
E.prototype.a=function(a,b){var c=a||"BESbswy",g=b||3E3,d="font-style:"+this.style+";font-variant:"+this.variant+";font-weight:"+this.weight+";font-stretch:"+this.stretch+";font-feature-settings:"+this.featureSettings+";-moz-font-feature-settings:"+this.featureSettings+";-webkit-font-feature-settings:"+this.featureSettings+";",h=document.createElement("div"),p=new f(c),q=new f(c),r=new f(c),k=-1,l=-1,m=-1,v=-1,w=-1,x=-1,t=this;return new D(function(a,b){function c(){null!==h.parentNode&&h.parentNode.removeChild(h)}
function y(){if(-1!==k&&-1!==l||-1!==k&&-1!==m||-1!==l&&-1!==m)if(k===l||k===m||l===m){if(null===F){var b=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);F=!!b&&(536>parseInt(b[1],10)||536===parseInt(b[1],10)&&11>=parseInt(b[2],10))}F?k===v&&l===v&&m===v||k===w&&l===w&&m===w||k===x&&l===x&&m===x||(c(),a(t)):(c(),a(t))}}e(function(){function a(){if(Date.now()-G>=g)c(),b(t);else{var d=document.hidden;if(!0===d||void 0===d)k=p.a.offsetWidth,l=q.a.offsetWidth,m=r.a.offsetWidth,
y();setTimeout(a,50)}}var G=Date.now();n(p,"sans-serif",d);n(q,"serif",d);n(r,"monospace",d);h.appendChild(p.a);h.appendChild(q.a);h.appendChild(r.a);document.body.appendChild(h);v=p.a.offsetWidth;w=q.a.offsetWidth;x=r.a.offsetWidth;a();z(p,function(a){k=a;y()});n(p,t.family+",sans-serif",d);z(q,function(a){l=a;y()});n(q,t.family+",serif",d);z(r,function(a){m=a;y()});n(r,t.family+",monospace",d)})})};window.FontFaceObserver=E;window.FontFaceObserver.prototype.check=E.prototype.a;}());

14

Gruntfile.js

@@ -29,3 +29,3 @@ var extend = require('extend');

},
deps: 'calcdeps -i src -i exports.js -p src -p ./vendor/google/base.js -p node_modules/closure-dom/src/dom.js -o deps > test/deps.js'
deps: 'calcdeps -i src -i exports.js -p src -p ./vendor/google/base.js -p node_modules/promis/src/ -p node_modules/closure-dom/src/dom.js -o deps > test/deps.js'
},

@@ -51,3 +51,3 @@ jshint: {

files: {
"fontfaceobserver.js": ['src/**/*.js', 'exports.js', 'node_modules/closure-dom/src/dom.js']
"fontfaceobserver.js": ['src/**/*.js', 'exports.js', 'node_modules/closure-dom/src/dom.js', 'node_modules/promis/src/**/*.js']
},

@@ -60,3 +60,3 @@ options: extend({}, compilerOptions, {

files: {
"build/fontfaceobserver.js": ['src/**/*.js', 'exports.js', 'node_modules/closure-dom/src/dom.js'],
"build/fontfaceobserver.js": ['src/**/*.js', 'exports.js', 'node_modules/closure-dom/src/dom.js', 'node_modules/promis/src/**/*.js'],
},

@@ -69,3 +69,3 @@ options: extend({}, compilerOptions, {

files: {
"build/fontfaceobserver.debug.js": ['src/**/*.js', 'exports.js', 'node_modules/closure-dom/src/dom.js']
"build/fontfaceobserver.debug.js": ['src/**/*.js', 'exports.js', 'node_modules/closure-dom/src/dom.js', 'node_modules/promis/src/**/*.js']
},

@@ -79,6 +79,2 @@ options: extend({}, compilerOptions, {

concat: {
dist_standalone: {
src: ['node_modules/promis/promise.js', 'build/fontfaceobserver.js'],
dest: 'fontfaceobserver.standalone.js'
},
dist: {

@@ -104,3 +100,3 @@ src: ['build/fontfaceobserver.js'],

grunt.registerTask('dev', ['connect', 'watch']);
grunt.registerTask('dist', ['clean', 'closurecompiler:compile', 'concat:dist', 'concat:dist_standalone']);
grunt.registerTask('dist', ['clean', 'closurecompiler:compile', 'concat:dist']);
};
{
"name": "fontfaceobserver",
"version": "1.4.8",
"version": "1.4.9",
"description": "Detect if web fonts are available",

@@ -22,3 +22,3 @@ "directories": {

"dependencies": {
"promis": "=1.0.2",
"promis": "=1.0.4",
"closure-dom": "=0.0.1"

@@ -25,0 +25,0 @@ },

# Font Face Observer
Font Face Observer is a small `@font-face` loader and monitor (3.1KB minified and 1.2KB gzipped) compatible with any web font service. It will monitor when a web font is applied to the page and notify you. It does not limit you in any way in where, when, or how you load your web fonts. Unlike the [Web Font Loader](https://github.com/typekit/webfontloader) Font Face Observer uses scroll events to detect font loads efficiently and with minimum overhead.
Font Face Observer is a small `@font-face` loader and monitor (4.6KB minified and 1.7KB gzipped) compatible with any web font service. It will monitor when a web font is applied to the page and notify you. It does not limit you in any way in where, when, or how you load your web fonts. Unlike the [Web Font Loader](https://github.com/typekit/webfontloader) Font Face Observer uses scroll events to detect font loads efficiently and with minimum overhead.

@@ -47,6 +47,4 @@ ## How to use

You can then either include `fontfaceobserver.js` or `fontfaceobserver.standalone.js`. The former is Font Face Observer without dependencies. The latter includes a small [promise polyfill](https://github.com/bramstein/promis).
You can then include `node_modules/fontfaceobserver/fontfaceobserver.js`. If you're not using npm, grab `fontfaceobserver.js` and include it in your project.
If you're not using npm, grab either `fontfaceobserver.js` or `fontfaceobserver.standalone.js` and include it in your project.
## Browser support

@@ -53,0 +51,0 @@

@@ -5,5 +5,7 @@ goog.provide('fontface.Observer');

goog.require('dom');
goog.require('lang.Promise');
goog.scope(function () {
var Ruler = fontface.Ruler;
var Ruler = fontface.Ruler,
Promise = lang.Promise;

@@ -10,0 +12,0 @@ /**

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc