You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

8 lines
13 KiB

8 months ago
/*!
* css-vars-ponyfill
* v1.4.0
* https://github.com/jhildenbiddle/css-vars-ponyfill
* (c) 2018 John Hildenbiddle <http://hildenbiddle.com>
* MIT license
*/
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.cssVars=n()}(this,function(){"use strict";function e(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={mimeType:n.mimeType||null,onComplete:n.onComplete||Function.prototype,onError:n.onError||Function.prototype,onSuccess:n.onSuccess||Function.prototype},t=Array.isArray(e)?e:[e],o=Array.apply(null,Array(t.length)).map(function(e){return null});function i(e,n){r.onError(e,t[n],n)}function s(e,n){o[n]=e,r.onSuccess(e,t[n],n),-1===o.indexOf(null)&&r.onComplete(o)}t.forEach(function(e,n){var t=document.createElement("a");t.setAttribute("href",e),t.href=t.href;var o=t.host!==location.host,a=t.protocol===location.protocol;if(o&&"undefined"!=typeof XDomainRequest)if(a){var u=new XDomainRequest;u.open("GET",e),u.timeout=0,u.onprogress=Function.prototype,u.ontimeout=Function.prototype,u.onload=function(){s(u.responseText,n)},u.onerror=function(e){i(u,n)},setTimeout(function(){u.send()},0)}else console.log("Internet Explorer 9 Cross-Origin (CORS) requests must use the same protocol"),i(null,n);else{var c=new XMLHttpRequest;c.open("GET",e),r.mimeType&&c.overrideMimeType&&c.overrideMimeType(r.mimeType),c.onreadystatechange=function(){4===c.readyState&&(200===c.status?s(c.responseText,n):i(c,n))},c.send()}})}function n(n){var t={cssComments:/\/\*[\s\S]+?\*\//g,cssImports:/(?:@import\s*)(?:url\(\s*)?(?:['"])([^'"]*)(?:['"])(?:\s*\))?(?:[^;]*;)/g},o={include:n.include||'style,link[rel="stylesheet"]',exclude:n.exclude||null,filter:n.filter||null,onComplete:n.onComplete||Function.prototype,onError:n.onError||Function.prototype,onSuccess:n.onSuccess||Function.prototype},i=Array.apply(null,document.querySelectorAll(o.include)).filter(function(e){return n=e,r=o.exclude,!(n.matches||n.matchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector||n.msMatchesSelector||n.oMatchesSelector).call(n,r);var n,r}),s=Array.apply(null,Array(i.length)).map(function(e){return null});function a(){if(-1===s.indexOf(null)){var e=s.join("");o.onComplete(e,s,i)}}function u(n,i,u,c){!function n(o,i,s){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];var u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];var c=o.replace(t.cssComments,"").match(t.cssImports);c=(c||[]).filter(function(e){return-1===u.indexOf(e)});if(c.length){var l=c.map(function(e){return e.replace(t.cssImports,"$1")}).map(function(e){return r(e,i)});e(l,{onError:function(e,r,t){a.push({xhr:e,url:r}),u.push(c[t]),n(o,i,s,a,u)},onSuccess:function(e,r,t){var i=c[t],l=o.replace(i,e);n(l,r,s,a,u)}})}else s(o,a)}(n,c,function(e,n){if(null===s[i]){if(n.forEach(function(e){return o.onError(e.xhr,u,e.url)}),!o.filter||o.filter.test(e)){var r=o.onSuccess(e,u,c);s[i]=!1===r?"":r||e}else s[i]="";a()}})}i.length?i.forEach(function(n,t){var i=n.getAttribute("href"),c=n.getAttribute("rel"),l="LINK"===n.nodeName&&i&&c&&"stylesheet"===c.toLowerCase(),f="STYLE"===n.nodeName;l?e(i,{mimeType:"text/css",onError:function(e,r,i){s[t]="",o.onError(e,n,r),a()},onSuccess:function(e,o,s){var a=r(i,location.href);u(e,t,n,a)}}):f?u(n.textContent,t,n,location.href):(s[t]="",a())}):o.onComplete("",[])}function r(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:location.href,r=document.implementation.createHTMLDocument(""),t=r.createElement("base"),o=r.createElement("a");return r.head.appendChild(t),r.body.appendChild(o),t.href=n,o.href=e,o.href}function t(){for(var e=function(e){return e instanceof Object&&e.constructor===Object},n=arguments.length,r=Array(n),o=0;o<n;o++)r[o]=arguments[o];return r.reduce(function(n,r){return Object.keys(r).forEach(function(o){var i=n[o],s=r[o];e(i)&&e(s)?n[o]=t(i,s):n[o]=s}),n},{})}var o=i;function i(e,n,r){e instanceof RegExp&&(e=s(e,r)),n instanceof RegExp&&(n=s(n,r));var t=a(e,n,r);return t&&{start:t[0],end:t[1],pre:r.slice(0,t[0]),body:r.slice(t[0]+e.length,t[1]),post:r.slice(t[1]+n.length)}}function s(e,n){var r=n.match(e);return r?r[0]:null}function a(e,n,r){var t,o,i,s,a,u=r.indexOf(e),c=r.