From 7546cd73830d3034be974c573fdd12ab015d89c0 Mon Sep 17 00:00:00 2001 From: long-m-r Date: Sun, 30 Aug 2015 14:29:22 -0500 Subject: [PATCH 1/4] Update css.js Modified to support requirejs error handling [line 149-153] Also added support for dynamic css servers (fixes issue sites like Google Fonts API. where the files is at https://fonts.googapis.com/icon?family=Material+Icons) [line 160,165] --- css.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/css.js b/css.js index d30bf98..9ca3940 100644 --- a/css.js +++ b/css.js @@ -146,21 +146,23 @@ define(function() { } }, 10); link.href = url; + // Support for requireJS error handling on links. Tested Chrome v44 & Firefox v40 + link.onerror=function(error){ + this.remove(); + callback.error(error); + } head.appendChild(link); } //>>excludeEnd('excludeRequireCss') cssAPI.normalize = function(name, normalize) { - if (name.substr(name.length - 4, 4) == '.css') - name = name.substr(0, name.length - 4); - - return normalize(name); + // Only append .css if it doesn't have it already or a ? + return normalize( /(\?|.css$)/.test(name) ? name : name+'.css' ); } //>>excludeStart('excludeRequireCss', pragmas.excludeRequireCss) cssAPI.load = function(cssId, req, load, config) { - - (useImportLoad ? importLoad : linkLoad)(req.toUrl(cssId + '.css'), load); + (useImportLoad ? importLoad : linkLoad)(req.toUrl(cssId), load); } From c4c5b24bafcd1316471d13e995c169754a8c211a Mon Sep 17 00:00:00 2001 From: long-m-r Date: Sun, 30 Aug 2015 14:35:23 -0500 Subject: [PATCH 2/4] Update css.min.js Update to match css.js changes --- css.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css.min.js b/css.min.js index 2e1d120..0b304cd 100644 --- a/css.min.js +++ b/css.min.js @@ -1 +1 @@ -define(function(){if("undefined"==typeof window)return{load:function(e,t,n){n()}};var e=document.getElementsByTagName("head")[0],t=window.navigator.userAgent.match(/Trident\/([^ ;]*)|AppleWebKit\/([^ ;]*)|Opera\/([^ ;]*)|rv\:([^ ;]*)(.*?)Gecko\/([^ ;]*)|MSIE\s([^ ;]*)|AndroidWebKit\/([^ ;]*)/)||0,n=!1,r=!0;t[1]||t[7]?n=parseInt(t[1])<6||parseInt(t[7])<=9:t[2]||t[8]?r=!1:t[4]&&(n=parseInt(t[4])<18);var o={};o.pluginBuilder="./css-builder";var a,i,s,l=function(){a=document.createElement("style"),e.appendChild(a),i=a.styleSheet||a.sheet},u=0,d=[],c=function(e){u++,32==u&&(l(),u=0),i.addImport(e),a.onload=function(){f()}},f=function(){s();var e=d.shift();return e?(s=e[1],void c(e[0])):void(s=null)},h=function(e,t){if(i&&i.addImport||l(),i&&i.addImport)s?d.push([e,t]):(c(e),s=t);else{a.textContent='@import "'+e+'";';var n=setInterval(function(){try{a.sheet.cssRules,clearInterval(n),t()}catch(e){}},10)}},p=function(t,n){var o=document.createElement("link");if(o.type="text/css",o.rel="stylesheet",r)o.onload=function(){o.onload=function(){},setTimeout(n,7)};else var a=setInterval(function(){for(var e=0;e Date: Sun, 30 Aug 2015 15:59:04 -0500 Subject: [PATCH 3/4] Update css.js typo in regex --- css.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css.js b/css.js index 9ca3940..2d0f346 100644 --- a/css.js +++ b/css.js @@ -157,7 +157,7 @@ define(function() { //>>excludeEnd('excludeRequireCss') cssAPI.normalize = function(name, normalize) { // Only append .css if it doesn't have it already or a ? - return normalize( /(\?|.css$)/.test(name) ? name : name+'.css' ); + return normalize( /(\?|\.css$)/.test(name) ? name : name+'.css' ); } //>>excludeStart('excludeRequireCss', pragmas.excludeRequireCss) From 62fdf587c016d8001bace40785bd8d732eaf37a7 Mon Sep 17 00:00:00 2001 From: long-m-r Date: Sun, 30 Aug 2015 16:01:21 -0500 Subject: [PATCH 4/4] Update css.min.js --- css.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css.min.js b/css.min.js index 0b304cd..923c99b 100644 --- a/css.min.js +++ b/css.min.js @@ -1 +1 @@ -define(function(){if(typeof window=="undefined")return{load:function(e,t,n){n()}};var e=document.getElementsByTagName("head")[0];var t=window.navigator.userAgent.match(/Trident\/([^ ;]*)|AppleWebKit\/([^ ;]*)|Opera\/([^ ;]*)|rv\:([^ ;]*)(.*?)Gecko\/([^ ;]*)|MSIE\s([^ ;]*)|AndroidWebKit\/([^ ;]*)/)||0;var n=false;var r=true;if(t[1]||t[7])n=parseInt(t[1])<6||parseInt(t[7])<=9;else if(t[2]||t[8])r=false;else if(t[4])n=parseInt(t[4])<18;var a={};a.pluginBuilder="./css-builder";var o,i;var s=function(){o=document.createElement("style");e.appendChild(o);i=o.styleSheet||o.sheet};var l=0;var f=[];var u;var c=function(e){i.addImport(e);o.onload=function(){d()};l++;if(l==31){s();l=0}};var d=function(){u();var e=f.shift();if(!e){u=null;return}u=e[1];c(e[0])};var v=function(e,t){if(!i||!i.addImport)s();if(i&&i.addImport){if(u){f.push([e,t])}else{c(e);u=t}}else{o.textContent='@import "'+e+'";';var n=setInterval(function(){try{o.sheet.cssRules;clearInterval(n);t()}catch(e){}},10)}};var h=function(t,n){var a=document.createElement("link");a.type="text/css";a.rel="stylesheet";if(r)a.onload=function(){a.onload=function(){};setTimeout(n,7)};else var o=setInterval(function(){for(var e=0;e