Skip to content

Commit 94d054b

Browse files
committed
Apply changes to new separate code path for pretty option
1 parent e56bed2 commit 94d054b

17 files changed

+895
-883
lines changed

dist/commonjs.js

Lines changed: 190 additions & 188 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/commonjs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
import{Fragment as e,options as t}from"preact";var r=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i,n=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,o=/[\s\n\\/='"\0<>]/,a=/^xlink:?./,i=/["&<]/;function l(e){if(!1===i.test(e+=""))return e;for(var t=0,r=0,n="",o="";r<e.length;r++){switch(e.charCodeAt(r)){case 34:o="&quot;";break;case 38:o="&amp;";break;case 60:o="&lt;";break;default:continue}r!==t&&(n+=e.slice(t,r)),n+=o,t=r+1}return r!==t&&(n+=e.slice(t,r)),n}var s=function(e,t){return String(e).replace(/(\n+)/g,"$1"+(t||"\t"))},f=function(e,t,r){return String(e).length>(t||40)||!r&&-1!==String(e).indexOf("\n")||-1!==String(e).indexOf("<")},c={},u=/([A-Z])/g;function p(e){var t="";for(var n in e){var o=e[n];null!=o&&""!==o&&(t&&(t+=" "),t+="-"==n[0]?n:c[n]||(c[n]=n.replace(u,"-$1").toLowerCase()),t="number"==typeof o&&!1===r.test(n)?t+": "+o+"px;":t+": "+o+";")}return t||void 0}function _(e,t){return Array.isArray(t)?t.reduce(_,e):null!=t&&!1!==t&&e.push(t),e}function d(){this.__d=!0}function v(e,t){return{__v:e,context:t,props:e.props,setState:d,forceUpdate:d,__d:!0,__h:[]}}function h(e,t){var r=e.contextType,n=r&&t[r.__c];return null!=r?n?n.props.value:r.__:t}var g=[];function y(r,i,c,u,d,m){if(null==r||"boolean"==typeof r)return"";if("object"!=typeof r)return l(r);var x=c.pretty,b=x&&"string"==typeof x?x:"\t";if(Array.isArray(r)){for(var k="",w=0;w<r.length;w++)x&&w>0&&(k+="\n"),k+=y(r[w],i,c,u,d,m);return k}var S,C=r.type,A=r.props,O=!1;if("function"==typeof C){if(O=!0,!c.shallow||!u&&!1!==c.renderRootComponent){if(C===e){var j=[];return _(j,r.props.children),y(j,i,c,!1!==c.shallowHighOrder,d,m)}var L,F=r.__c=v(r,i);t.__b&&t.__b(r);var H=t.__r;if(C.prototype&&"function"==typeof C.prototype.render){var M=h(C,i);(F=r.__c=new C(A,M)).__v=r,F._dirty=F.__d=!0,F.props=A,null==F.state&&(F.state={}),null==F._nextState&&null==F.__s&&(F._nextState=F.__s=F.state),F.context=M,C.getDerivedStateFromProps?F.state=Object.assign({},F.state,C.getDerivedStateFromProps(F.props,F.state)):F.componentWillMount&&(F.componentWillMount(),F.state=F._nextState!==F.state?F._nextState:F.__s!==F.state?F.__s:F.state),H&&H(r),L=F.render(F.props,F.state,F.context)}else for(var $=h(C,i),E=0;F.__d&&E++<25;)F.__d=!1,H&&H(r),L=C.call(r.__c,A,$);return F.getChildContext&&(i=Object.assign({},i,F.getChildContext())),t.diffed&&t.diffed(r),y(L,i,c,!1!==c.shallowHighOrder,d,m)}C=(S=C).displayName||S!==Function&&S.name||function(e){var t=(Function.prototype.toString.call(e).match(/^\s*function\s+([^( ]+)/)||"")[1];if(!t){for(var r=-1,n=g.length;n--;)if(g[n]===e){r=n;break}r<0&&(r=g.push(e)-1),t="UnnamedComponent"+r}return t}(S)}var T,P,D="<"+C;if(A){var N=Object.keys(A);c&&!0===c.sortAttributes&&N.sort();for(var W=0;W<N.length;W++){var Z=N[W],I=A[Z];if("children"!==Z){if(!o.test(Z)&&(c&&c.allAttributes||"key"!==Z&&"ref"!==Z&&"__self"!==Z&&"__source"!==Z)){if("defaultValue"===Z)Z="value";else if("defaultChecked"===Z)Z="checked";else if("defaultSelected"===Z)Z="selected";else if("className"===Z){if(void 0!==A.class)continue;Z="class"}else d&&a.test(Z)&&(Z=Z.toLowerCase().replace(/^xlink:?/,"xlink:"));if("htmlFor"===Z){if(A.for)continue;Z="for"}"style"===Z&&I&&"object"==typeof I&&(I=p(I)),"a"===Z[0]&&"r"===Z[1]&&"boolean"==typeof I&&(I=String(I));var R=c.attributeHook&&c.attributeHook(Z,I,i,c,O);if(R||""===R)D+=R;else if("dangerouslySetInnerHTML"===Z)P=I&&I.__html;else if("textarea"===C&&"value"===Z)T=I;else if((I||0===I||""===I)&&"function"!=typeof I){if(!(!0!==I&&""!==I||(I=Z,c&&c.xml))){D=D+" "+Z;continue}if("value"===Z){if("select"===C){m=I;continue}"option"===C&&m==I&&void 0===A.selected&&(D+=" selected")}D=D+" "+Z+'="'+l(I)+'"'}}}else T=I}}if(x){var U=D.replace(/\n\s*/," ");U===D||~U.indexOf("\n")?x&&~D.indexOf("\n")&&(D+="\n"):D=U}if(D+=">",o.test(C))throw new Error(C+" is not a valid HTML tag name in "+D);var V,q=n.test(C)||c.voidElements&&c.voidElements.test(C),z=[];if(P)x&&f(P)&&(P="\n"+b+s(P,b)),D+=P;else if(null!=T&&_(V=[],T).length){for(var B=x&&~D.indexOf("\n"),G=!1,J=0;J<V.length;J++){var K=V[J];if(null!=K&&!1!==K){var Q=y(K,i,c,!0,"svg"===C||"foreignObject"!==C&&d,m);if(x&&!B&&f(Q)&&(B=!0),Q)if(x){var X=Q.length>0&&"<"!=Q[0];G&&X?z[z.length-1]+=Q:z.push(Q),G=X}else z.push(Q)}}if(x&&B)for(var Y=z.length;Y--;)z[Y]="\n"+b+s(z[Y],b)}if(z.length||P)D+=z.join("");else if(c&&c.xml)return D.substring(0,D.length-1)+" />";return!q||V||P?(x&&~D.indexOf("\n")&&(D+="\n"),D=D+"</"+C+">"):D=D.replace(/>$/," />"),D}var m={shallow:!0};k.render=k;var x=function(e,t){return k(e,t,m)},b=[];function k(e,r,n){r=r||{};var o,a=t.__s;return t.__s=!0,o=n&&(n.pretty||n.voidElements||n.sortAttributes||n.shallow||n.allAttributes||n.xml||n.attributeHook)?y(e,r,n):O(e,r,!1,void 0),t.__c&&t.__c(e,b),t.__s=a,b.length=0,o}function w(e,t){return"className"===e?"class":"htmlFor"===e?"for":"defaultValue"===e?"value":"defaultChecked"===e?"checked":"defaultSelected"===e?"selected":t&&a.test(e)?e.toLowerCase().replace(/^xlink:?/,"xlink:"):e}function S(e,t){return"style"===e&&null!=t&&"object"==typeof t?p(t):"a"===e[0]&&"r"===e[1]&&"boolean"==typeof t?String(t):t}var C=Array.isArray,A=Object.assign;function O(r,a,i,s){if(null==r||!0===r||!1===r||""===r)return"";if("object"!=typeof r)return l(r);if(C(r)){for(var f="",c=0;c<r.length;c++)f+=O(r[c],a,i,s);return f}var u=r.type,p=r.props;if("function"==typeof u){if(u===e)return O(r.props.children,a,i,s);var _;t.__b&&t.__b(r),_=u.prototype&&"function"==typeof u.prototype.render?function(e,r){var n=e.type,o=h(n,r),a=new n(e.props,o);e.__c=a,a.__v=e,a.__d=!0,a.props=e.props,null==a.state&&(a.state={}),null==a.__s&&(a.__s=a.state),a.context=o,n.getDerivedStateFromProps?a.state=A({},a.state,n.getDerivedStateFromProps(a.props,a.state)):a.componentWillMount&&(a.componentWillMount(),a.state=a.__s!==a.state?a.__s:a.state);var i=t.__r;return i&&i(e),a.render(a.props,a.state,a.context)}(r,a):function(e,r){var n,o=v(e,r),a=h(e.type,r);e.__c=o;for(var i=t.__r,l=0;o.__d&&l++<25;)o.__d=!1,i&&i(e),n=e.type.call(o,e.props,a);return n}(r,a);var d=r.__c;return d.getChildContext&&(a=A({},a,d.getChildContext())),t.diffed&&t.diffed(r),O(_,a,i,s)}var g,y,m="<";if(m+=u,p)for(var x in g=p.children,p){var b=p[x];if(!("key"===x||"ref"===x||"__self"===x||"__source"===x||"children"===x||"className"===x&&"class"in p||"htmlFor"===x&&"for"in p||o.test(x)))if(b=S(x=w(x,i),b),"dangerouslySetInnerHTML"===x)y=b&&b.__html;else if("textarea"===u&&"value"===x)g=b;else if((b||0===b||""===b)&&"function"!=typeof b){if(x=M(x),!0===b||""===b){b=x,m=m+" "+x;continue}if("value"===x){if("select"===u){s=b;continue}"option"!==u||s!=b||"selected"in p||(m+=" selected")}m=m+" "+x+'="'+l(b)+'"'}}var k=m;if(m+=">",o.test(u))throw new Error(u+" is not a valid HTML tag name in "+m);var j="",L=!1;if(y)j+=y,L=!0;else if("string"==typeof g)j+=l(g),L=!0;else if(C(g))for(var F=0;F<g.length;F++){var H=g[F];if(null!=H&&!1!==H){var $=O(H,a,"svg"===u||"foreignObject"!==u&&i,s);$&&(j+=$,L=!0)}}else if(null!=g&&!1!==g&&!0!==g){var E=O(g,a,"svg"===u||"foreignObject"!==u&&i,s);E&&(j+=E,L=!0)}if(L)m+=j;else if(n.test(u))return k+" />";return m+"</"+u+">"}var j=/^(acceptC|httpE|(clip|color|fill|font|glyph|marker|stop|stroke|text|vert)[A-Z])/,L=/^(isP|viewB)/,F=/^(xlink|xml|xmlns)[A-Z]/,H=/([A-Z])/g;function M(e){return L.test(e)?e:j.test(e)?e.replace(H,"-$1").toLowerCase():F.test(e)?e.replace(H,":$1").toLowerCase():e.toLowerCase()}k.shallowRender=x;export default k;export{k as render,k as renderToStaticMarkup,k as renderToString,x as shallowRender};
1+
import{Fragment as e,options as t}from"preact";var r=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i,n=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,o=/[\s\n\\/='"\0<>]/,a=/^xlink:?./,i=/["&<]/;function l(e){if(!1===i.test(e+=""))return e;for(var t=0,r=0,n="",o="";r<e.length;r++){switch(e.charCodeAt(r)){case 34:o="&quot;";break;case 38:o="&amp;";break;case 60:o="&lt;";break;default:continue}r!==t&&(n+=e.slice(t,r)),n+=o,t=r+1}return r!==t&&(n+=e.slice(t,r)),n}var s=function(e,t){return String(e).replace(/(\n+)/g,"$1"+(t||"\t"))},f=function(e,t,r){return String(e).length>(t||40)||!r&&-1!==String(e).indexOf("\n")||-1!==String(e).indexOf("<")},c={},u=/([A-Z])/g;function p(e){var t="";for(var n in e){var o=e[n];null!=o&&""!==o&&(t&&(t+=" "),t+="-"==n[0]?n:c[n]||(c[n]=n.replace(u,"-$1").toLowerCase()),t="number"==typeof o&&!1===r.test(n)?t+": "+o+"px;":t+": "+o+";")}return t||void 0}function _(e,t){return Array.isArray(t)?t.reduce(_,e):null!=t&&!1!==t&&e.push(t),e}function d(){this.__d=!0}function v(e,t){return{__v:e,context:t,props:e.props,setState:d,forceUpdate:d,__d:!0,__h:[]}}function h(e,t){var r=e.contextType,n=r&&t[r.__c];return null!=r?n?n.props.value:r.__:t}var g=/^(acceptC|httpE|(clip|color|fill|font|glyph|marker|stop|stroke|text|vert)[A-Z])/,y=/^(isP|viewB)/,m=/^(xlink|xml|xmlns)[A-Z]/,x=/([A-Z])/g;function b(e){return y.test(e)?e:g.test(e)?e.replace(x,"-$1").toLowerCase():m.test(e)?e.replace(x,":$1").toLowerCase():e.toLowerCase()}var k=[];function w(r,i,c,u,d,g){if(null==r||"boolean"==typeof r)return"";if("object"!=typeof r)return l(r);var y=c.pretty,m=y&&"string"==typeof y?y:"\t";if(Array.isArray(r)){for(var x="",S=0;S<r.length;S++)y&&S>0&&(x+="\n"),x+=w(r[S],i,c,u,d,g);return x}var C,A=r.type,O=r.props,j=!1;if("function"==typeof A){if(j=!0,!c.shallow||!u&&!1!==c.renderRootComponent){if(A===e){var L=[];return _(L,r.props.children),w(L,i,c,!1!==c.shallowHighOrder,d,g)}var F,H=r.__c=v(r,i);t.__b&&t.__b(r);var M=t.__r;if(A.prototype&&"function"==typeof A.prototype.render){var $=h(A,i);(H=r.__c=new A(O,$)).__v=r,H._dirty=H.__d=!0,H.props=O,null==H.state&&(H.state={}),null==H._nextState&&null==H.__s&&(H._nextState=H.__s=H.state),H.context=$,A.getDerivedStateFromProps?H.state=Object.assign({},H.state,A.getDerivedStateFromProps(H.props,H.state)):H.componentWillMount&&(H.componentWillMount(),H.state=H._nextState!==H.state?H._nextState:H.__s!==H.state?H.__s:H.state),M&&M(r),F=H.render(H.props,H.state,H.context)}else for(var E=h(A,i),T=0;H.__d&&T++<25;)H.__d=!1,M&&M(r),F=A.call(r.__c,O,E);return H.getChildContext&&(i=Object.assign({},i,H.getChildContext())),t.diffed&&t.diffed(r),w(F,i,c,!1!==c.shallowHighOrder,d,g)}A=(C=A).displayName||C!==Function&&C.name||function(e){var t=(Function.prototype.toString.call(e).match(/^\s*function\s+([^( ]+)/)||"")[1];if(!t){for(var r=-1,n=k.length;n--;)if(k[n]===e){r=n;break}r<0&&(r=k.push(e)-1),t="UnnamedComponent"+r}return t}(C)}var P,D,N="<"+A;if(O){var W=Object.keys(O);c&&!0===c.sortAttributes&&W.sort();for(var Z=0;Z<W.length;Z++){var I=W[Z],R=O[I];if("children"!==I){if(!o.test(I)&&(c&&c.allAttributes||"key"!==I&&"ref"!==I&&"__self"!==I&&"__source"!==I)){if("defaultValue"===I)I="value";else if("defaultChecked"===I)I="checked";else if("defaultSelected"===I)I="selected";else if("className"===I){if(void 0!==O.class)continue;I="class"}else d&&a.test(I)&&(I=I.toLowerCase().replace(/^xlink:?/,"xlink:"));if("htmlFor"===I){if(O.for)continue;I="for"}"style"===I&&R&&"object"==typeof R&&(R=p(R)),"a"===I[0]&&"r"===I[1]&&"boolean"==typeof R&&(R=String(R));var U=c.attributeHook&&c.attributeHook(I,R,i,c,j);if(U||""===U)N+=U;else if("dangerouslySetInnerHTML"===I)D=R&&R.__html;else if("textarea"===A&&"value"===I)P=R;else if((R||0===R||""===R)&&"function"!=typeof R){if(I=b(I),!(!0!==R&&""!==R||(R=I,c&&c.xml))){N=N+" "+I;continue}if("value"===I){if("select"===A){g=R;continue}"option"===A&&g==R&&void 0===O.selected&&(N+=" selected")}N=N+" "+I+'="'+l(R)+'"'}}}else P=R}}if(y){var V=N.replace(/\n\s*/," ");V===N||~V.indexOf("\n")?y&&~N.indexOf("\n")&&(N+="\n"):N=V}if(N+=">",o.test(A))throw new Error(A+" is not a valid HTML tag name in "+N);var q,z=n.test(A)||c.voidElements&&c.voidElements.test(A),B=[];if(D)y&&f(D)&&(D="\n"+m+s(D,m)),N+=D;else if(null!=P&&_(q=[],P).length){for(var G=y&&~N.indexOf("\n"),J=!1,K=0;K<q.length;K++){var Q=q[K];if(null!=Q&&!1!==Q){var X=w(Q,i,c,!0,"svg"===A||"foreignObject"!==A&&d,g);if(y&&!G&&f(X)&&(G=!0),X)if(y){var Y=X.length>0&&"<"!=X[0];J&&Y?B[B.length-1]+=X:B.push(X),J=Y}else B.push(X)}}if(y&&G)for(var ee=B.length;ee--;)B[ee]="\n"+m+s(B[ee],m)}if(B.length||D)N+=B.join("");else if(c&&c.xml)return N.substring(0,N.length-1)+" />";return!z||q||D?(y&&~N.indexOf("\n")&&(N+="\n"),N=N+"</"+A+">"):N=N.replace(/>$/," />"),N}var S={shallow:!0};O.render=O;var C=function(e,t){return O(e,t,S)},A=[];function O(e,r,n){r=r||{};var o,a=t.__s;return t.__s=!0,o=n&&(n.pretty||n.voidElements||n.sortAttributes||n.shallow||n.allAttributes||n.xml||n.attributeHook)?w(e,r,n):M(e,r,!1,void 0),t.__c&&t.__c(e,A),t.__s=a,A.length=0,o}function j(e,t){return"className"===e?"class":"htmlFor"===e?"for":"defaultValue"===e?"value":"defaultChecked"===e?"checked":"defaultSelected"===e?"selected":t&&a.test(e)?e.toLowerCase().replace(/^xlink:?/,"xlink:"):e}function L(e,t){return"style"===e&&null!=t&&"object"==typeof t?p(t):"a"===e[0]&&"r"===e[1]&&"boolean"==typeof t?String(t):t}var F=Array.isArray,H=Object.assign;function M(r,a,i,s){if(null==r||!0===r||!1===r||""===r)return"";if("object"!=typeof r)return l(r);if(F(r)){for(var f="",c=0;c<r.length;c++)f+=M(r[c],a,i,s);return f}var u=r.type,p=r.props;if("function"==typeof u){if(u===e)return M(r.props.children,a,i,s);var _;t.__b&&t.__b(r),_=u.prototype&&"function"==typeof u.prototype.render?function(e,r){var n=e.type,o=h(n,r),a=new n(e.props,o);e.__c=a,a.__v=e,a.__d=!0,a.props=e.props,null==a.state&&(a.state={}),null==a.__s&&(a.__s=a.state),a.context=o,n.getDerivedStateFromProps?a.state=H({},a.state,n.getDerivedStateFromProps(a.props,a.state)):a.componentWillMount&&(a.componentWillMount(),a.state=a.__s!==a.state?a.__s:a.state);var i=t.__r;return i&&i(e),a.render(a.props,a.state,a.context)}(r,a):function(e,r){var n,o=v(e,r),a=h(e.type,r);e.__c=o;for(var i=t.__r,l=0;o.__d&&l++<25;)o.__d=!1,i&&i(e),n=e.type.call(o,e.props,a);return n}(r,a);var d=r.__c;return d.getChildContext&&(a=H({},a,d.getChildContext())),t.diffed&&t.diffed(r),M(_,a,i,s)}var g,y,m="<";if(m+=u,p)for(var x in g=p.children,p){var k=p[x];if(!("key"===x||"ref"===x||"__self"===x||"__source"===x||"children"===x||"className"===x&&"class"in p||"htmlFor"===x&&"for"in p||o.test(x)))if(k=L(x=j(x,i),k),"dangerouslySetInnerHTML"===x)y=k&&k.__html;else if("textarea"===u&&"value"===x)g=k;else if((k||0===k||""===k)&&"function"!=typeof k){if(x=b(x),!0===k||""===k){k=x,m=m+" "+x;continue}if("value"===x){if("select"===u){s=k;continue}"option"!==u||s!=k||"selected"in p||(m+=" selected")}m=m+" "+x+'="'+l(k)+'"'}}var w=m;if(m+=">",o.test(u))throw new Error(u+" is not a valid HTML tag name in "+m);var S="",C=!1;if(y)S+=y,C=!0;else if("string"==typeof g)S+=l(g),C=!0;else if(F(g))for(var A=0;A<g.length;A++){var O=g[A];if(null!=O&&!1!==O){var $=M(O,a,"svg"===u||"foreignObject"!==u&&i,s);$&&(S+=$,C=!0)}}else if(null!=g&&!1!==g&&!0!==g){var E=M(g,a,"svg"===u||"foreignObject"!==u&&i,s);E&&(S+=E,C=!0)}if(C)m+=S;else if(n.test(u))return w+" />";return m+"</"+u+">"}O.shallowRender=C;export default O;export{O as render,O as renderToStaticMarkup,O as renderToString,C as shallowRender};
22
//# sourceMappingURL=index.module.js.map

0 commit comments

Comments
 (0)