This repository has been archived by the owner on Jul 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
apply-shim.min.js
25 lines (23 loc) · 6.12 KB
/
apply-shim.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(function(){
/*
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
'use strict';var n=/(?:^|[;\s{]\s*)(--[\w-]*?)\s*:\s*(?:([^;{]*)|{([^}]*)})(?:(?=[;\s}])|$)/gi,q=/(?:^|\W+)@apply\s*\(?([^);\n]*)\)?/gi,r=/@media[^(]*(\([^)]*\))/;var v=!navigator.userAgent.match("AppleWebKit/601")&&window.CSS&&CSS.supports&&CSS.supports("box-shadow","0 0 0 var(--foo)");function w(c){c&&(v=v&&!c.shimcssproperties)}window.a?w(window.ShadyCSS):window.b&&w(window.WebComponents.flags);var x=v;function y(){this.end=this.start=0;this.rules=this.parent=this.previous=null;this.cssText=this.parsedCssText="";this.atRule=!1;this.type=0;this.parsedSelector=this.selector=this.keyframesName=""}
function z(c){c=c.replace(A,"").replace(B,"");var e=C,d=c,f=new y;f.start=0;f.end=d.length;for(var g=f,h=0,l=d.length;h<l;h++)if("{"===d[h]){g.rules||(g.rules=[]);var k=g,m=k.rules[k.rules.length-1]||null,g=new y;g.start=h+1;g.parent=k;g.previous=m;k.rules.push(g)}else"}"===d[h]&&(g.end=h+1,g=g.parent||f);return e(f,c)}
function C(c,e){var d=e.substring(c.start,c.end-1);c.parsedCssText=c.cssText=d.trim();c.parent&&((d=e.substring(c.previous?c.previous.end:c.parent.start,c.start-1),d=D(d),d=d.replace(E," "),d=d.substring(d.lastIndexOf(";")+1),d=c.parsedSelector=c.selector=d.trim(),c.atRule=!d.indexOf("@"),c.atRule)?d.indexOf("@media")?d.match(G)&&(c.type=H,c.keyframesName=c.selector.split(E).pop()):c.type=F:c.type=d.indexOf("--")?I:J);if(d=c.rules)for(var f=0,g=d.length,h;f<g&&(h=d[f]);f++)C(h,e);return c}
function D(c){return c.replace(/\\([0-9a-f]{1,6})\s/gi,function(c,d){c=d;for(d=6-c.length;d--;)c="0"+c;return"\\"+c})}
function K(c,e,d){d=void 0===d?"":d;var f="";if(c.cssText||c.rules){var g=c.rules,h;if(h=g)h=g[0],h=!(h&&h.selector&&0===h.selector.indexOf("--"));if(h){h=0;for(var l=g.length,k;h<l&&(k=g[h]);h++)f=K(k,e,f)}else e?e=c.cssText:(e=c.cssText,e=e.replace(L,"").replace(M,""),e=e.replace(N,"").replace(Q,"")),(f=e.trim())&&(f=" "+f+"\n")}f&&(c.selector&&(d+=c.selector+" {\n"),d+=f,c.selector&&(d+="}\n\n"));return d}
var I=1,H=7,F=4,J=1E3,A=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,B=/@import[^;]*;/gim,L=/(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?(?:[;\n]|$)/gim,M=/(?:^[^;\-\s}]+)?--[^;{}]*?:[^{};]*?{[^}]*?}(?:[;\n]|$)?/gim,N=/@apply\s*\(?[^);]*\)?\s*(?:[;\n]|$)?/gim,Q=/[^;:]*?:[^;]*?var\([^;]*\)(?:[;\n]|$)?/gim,G=/^@[^\s]*keyframes/,E=/\s+/g;function R(c){"string"===typeof c&&(c=z(c));return K(c,x)}function S(c){!c.__cssRules&&c.textContent&&(c.__cssRules=z(c.textContent));return c.__cssRules}function T(c,e,d,f){if(c){var g=!1,h=c.type;if(f&&h===F){var l=c.selector.match(r);l&&(window.matchMedia(l[1]).matches||(g=!0))}h===I?e(c):d&&h===H?d(c):h===J&&(g=!0);if((c=c.rules)&&!g)for(var g=0,h=c.length,k;g<h&&(k=c[g]);g++)T(k,e,d,f)}}
function U(c,e){var d=c.indexOf("var(");if(-1===d)return e(c,"","","");var f;a:{var g=0;f=d+3;for(var h=c.length;f<h;f++)if("("===c[f])g++;else if(")"===c[f]&&!--g)break a;f=-1}g=c.substring(d+4,f);d=c.substring(0,d);c=U(c.substring(f+1),e);f=g.indexOf(",");return-1===f?e(d,g.trim(),"",c):e(d,g.substring(0,f).trim(),g.substring(f+1).trim(),c)};var aa=/;\s*/m,ba=/^\s*(initial)|(inherit)\s*$/;function V(){this.a={}}V.prototype.set=function(c,e){c=c.trim();this.a[c]={g:e,h:{}}};V.prototype.get=function(c){c=c.trim();return this.a[c]||null};var W=null;function X(){this.b=this.c=null;this.a=new V}X.prototype.l=function(c){c=q.test(c)||n.test(c);q.lastIndex=0;n.lastIndex=0;return c};X.prototype.o=function(c,e){c=c.content.querySelector("style");var d=null;c&&(d=this.i(c,e));return d};
X.prototype.i=function(c,e){e=void 0===e?"":e;var d=S(c);this.j(d,e);c.textContent=R(d);return d};X.prototype.m=function(c){var e=this,d=S(c);T(d,function(c){":root"===c.selector&&(c.selector="html");e.f(c)});c.textContent=R(d);return d};X.prototype.j=function(c,e){var d=this;this.c=e;T(c,function(c){d.f(c)});this.c=null};X.prototype.f=function(c){c.cssText=ca(this,c.parsedCssText);":root"===c.selector&&(c.selector=":host > *")};
function ca(c,e){e=e.replace(n,function(d,e,g,h){return da(c,d,e,g,h)});return Y(c,e)}function Y(c,e){for(var d;d=q.exec(e);){var f=d[0],g=d[1];d=d.index;var h=e.slice(0,d+f.indexOf("@apply"));e=e.slice(d+f.length);var l=Z(c,h),k,m,f=void 0;k=c;var g=g.replace(aa,""),p=[];m=k.a.get(g);m||(k.a.set(g,{}),m=k.a.get(g));if(m)for(f in k.c&&(m.h[k.c]=!0),m.g)k=l&&l[f],m=[f,": var(",g,"_-_",f],k&&m.push(",",k),m.push(")"),p.push(m.join(""));f=p.join("; ");e=""+h+f+e;q.lastIndex=d+f.length}return e}
function Z(c,e){e=e.split(";");for(var d,f,g={},h=0,l;h<e.length;h++)if(d=e[h])if(l=d.split(":"),1<l.length){d=l[0].trim();var k=c;f=d;l=l.slice(1).join(":");var m=ba.exec(l);m&&(m[1]?(k.b||(k.b=document.createElement("meta"),k.b.setAttribute("apply-shim-measure",""),k.b.style.all="initial",document.head.appendChild(k.b)),f=window.getComputedStyle(k.b).getPropertyValue(f)):f="apply-shim-inherit",l=f);f=l;g[d]=f}return g}function ea(c,e){if(W)for(var d in e.h)d!==c.c&&W(d)}
function da(c,e,d,f,g){f&&U(f,function(d,e){e&&c.a.get(e)&&(g="@apply "+e+";")});if(!g)return e;var h=Y(c,g),l=e.slice(0,e.indexOf("--")),k=h=Z(c,h),m=c.a.get(d),p=m&&m.g;p?k=Object.assign(Object.create(p),h):c.a.set(d,k);var O=[],t,u,P=!1;for(t in k)u=h[t],void 0===u&&(u="initial"),!p||t in p||(P=!0),O.push(""+d+"_-_"+t+": "+u);P&&ea(c,m);m&&(m.g=k);f&&(l=e+";"+l);return""+l+O.join("; ")+";"}X.prototype.detectMixin=X.prototype.l;X.prototype.transformStyle=X.prototype.i;
X.prototype.transformCustomStyle=X.prototype.m;X.prototype.transformRules=X.prototype.j;X.prototype.transformRule=X.prototype.f;X.prototype.transformTemplate=X.prototype.o;X.prototype._separator="_-_";Object.defineProperty(X.prototype,"invalidCallback",{get:function(){return W},set:function(c){W=c}});window.ApplyShim||(window.ApplyShim=new X);
}).call(self)
//# sourceMappingURL=apply-shim.min.js.map