From 89bb592d3b0c2a3ba14ddea1c3f2b29376d54745 Mon Sep 17 00:00:00 2001 From: Andrea Giammarchi Date: Wed, 21 Nov 2018 13:51:58 +0100 Subject: [PATCH 001/151] Fix #293 - info.setProperty is not a function --- cjs/objects/Style.js | 2 +- esm.js | 2 +- esm/objects/Style.js | 2 +- index.js | 2 +- min.js | 2 +- umd.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cjs/objects/Style.js b/cjs/objects/Style.js index a11a1d64..debf986f 100644 --- a/cjs/objects/Style.js +++ b/cjs/objects/Style.js @@ -45,7 +45,7 @@ const update = (style, isSVG) => { const styleValue = typeof value === 'number' && !IS_NON_DIMENSIONAL.test(key) ? (value + 'px') : value; - if (/^--/.test(key)) + if (!isSVG && /^--/.test(key)) info.setProperty(key, styleValue); else info[key] = styleValue; diff --git a/esm.js b/esm.js index f84f0473..5d6265fe 100644 --- a/esm.js +++ b/esm.js @@ -1,4 +1,4 @@ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){this.childNodes=e,this.length=e.length,this.first=e[0],this.last=e[this.length-1],this._=null}function r(){}function i(e){var t=Fe.get(this);return t&&t.template===Y(e)?a.apply(t.updates,arguments):o.apply(this,arguments),this}function o(e){e=Y(e);var t=Be.get(e)||u.call(this,e),n=U(this.ownerDocument,t.fragment),r=ze.create(n,t.paths);Fe.set(this,{template:e,updates:r}),a.apply(r,arguments),this.textContent="",this.appendChild(n)}function a(){for(var e=arguments.length,t=1;t\"'=]+",M="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",$="(?:=(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",_=new RegExp(M+L+$+"+)([ "+T+"]*/?>)","g"),D=new RegExp(M+L+$+"*)([ "+T+"]*/>)","g"),P=function(e,t){return R(e).createElement(t)},R=function(e){return e.ownerDocument||e},H=function(e){return R(e).createDocumentFragment()},W=function(e,t){return R(e).createTextNode(t)},z=H(document),F="append"in z,B="content"in P(document,"template");z.appendChild(W(z,"g")),z.appendChild(W(z,""));var Z=1===z.cloneNode(!0).childNodes.length,V="importNode"in document,G=F?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"+t+"",G(r,X.call(n.querySelectorAll(i)))}else n.innerHTML=t,G(r,X.call(n.childNodes));return r},ne=B?function(e,t){var n=H(e),r=R(e).createElementNS(s,"svg");return r.innerHTML=t,G(n,X.call(r.childNodes)),n}:function(e,t){var n=H(e),r=P(e,"div");return r.innerHTML=''+t+"",G(n,X.call(r.firstChild.childNodes)),n};n.prototype.valueOf=function(e){var t=null==this._;return t&&(this._=H(this.first)),(t||e)&&G(this._,this.childNodes),this._},n.prototype.remove=function(){this._=null;var e=this.first,t=this.last;if(2===this.length)t.parentNode.removeChild(t);else{var n=R(e).createRange();n.setStartBefore(this.childNodes[1]),n.setEndAfter(t),n.deleteContents()}return e};var re=function(e){var t=[],n=void 0;switch(e.nodeType){case 1:case 11:n=e;break;case 8:n=e.parentNode,ie(t,n,e);break;default:n=e.ownerElement}for(e=n;n=n.parentNode;e=n)ie(t,n,e);return t},ie=function(e,t,n){e.unshift(e.indexOf.call(t.childNodes,n))},oe={create:function(e,t,n){return{type:e,name:n,node:t,path:re(t)}},find:function(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var g=Array(l),b=f[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},Ne=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,f=void 0,s=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],f=-l;f<=l;f+=2){for(d=f===-l||f!==l&&h[p+f-1]=0;l--){for(;d>0&&s>0&&a(r[i+d-1],e[t+s-1]);)m[g--]=0,d--,s--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],f=d-s,f===-l||f!==l&&h[p+f-1]>>0;n\"'=]+",M="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",$="(?:=(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",_=new RegExp(M+L+$+"+)([ "+T+"]*/?>)","g"),D=new RegExp(M+L+$+"*)([ "+T+"]*/>)","g"),P=function(e,t){return R(e).createElement(t)},R=function(e){return e.ownerDocument||e},H=function(e){return R(e).createDocumentFragment()},W=function(e,t){return R(e).createTextNode(t)},z=H(document),F="append"in z,B="content"in P(document,"template");z.appendChild(W(z,"g")),z.appendChild(W(z,""));var Z=1===z.cloneNode(!0).childNodes.length,V="importNode"in document,G=F?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"+t+"",G(r,X.call(n.querySelectorAll(i)))}else n.innerHTML=t,G(r,X.call(n.childNodes));return r},ne=B?function(e,t){var n=H(e),r=R(e).createElementNS(s,"svg");return r.innerHTML=t,G(n,X.call(r.childNodes)),n}:function(e,t){var n=H(e),r=P(e,"div");return r.innerHTML=''+t+"",G(n,X.call(r.firstChild.childNodes)),n};n.prototype.valueOf=function(e){var t=null==this._;return t&&(this._=H(this.first)),(t||e)&&G(this._,this.childNodes),this._},n.prototype.remove=function(){this._=null;var e=this.first,t=this.last;if(2===this.length)t.parentNode.removeChild(t);else{var n=R(e).createRange();n.setStartBefore(this.childNodes[1]),n.setEndAfter(t),n.deleteContents()}return e};var re=function(e){var t=[],n=void 0;switch(e.nodeType){case 1:case 11:n=e;break;case 8:n=e.parentNode,ie(t,n,e);break;default:n=e.ownerElement}for(e=n;n=n.parentNode;e=n)ie(t,n,e);return t},ie=function(e,t,n){e.unshift(e.indexOf.call(t.childNodes,n))},oe={create:function(e,t,n){return{type:e,name:n,node:t,path:re(t)}},find:function(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var g=Array(l),b=f[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},Ne=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,f=void 0,s=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],f=-l;f<=l;f+=2){for(d=f===-l||f!==l&&h[p+f-1]=0;l--){for(;d>0&&s>0&&a(r[i+d-1],e[t+s-1]);)m[g--]=0,d--,s--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],f=d-s,f===-l||f!==l&&h[p+f-1]>>0;n"},Ge=new b,Ie=function(e,t){return null==e?qe(t||"html"):Je(e,t||"html")},qe=function(e){var t=void 0,n=void 0,r=void 0,o=void 0,a=void 0;return function(u){u=Y(u);var c=o!==u;return c&&(o=u,r=H(document),n="svg"===e?document.createElementNS(s,"svg"):r,a=i.bind(n)),a.apply(null,arguments),c&&("svg"===e&&G(r,X.call(n.childNodes)),t=Ke(r)),t}},Je=function(e,t){var n=t.indexOf(":"),r=Ge.get(e),i=t;return-1 { const styleValue = typeof value === 'number' && !IS_NON_DIMENSIONAL.test(key) ? (value + 'px') : value; - if (/^--/.test(key)) + if (!isSVG && /^--/.test(key)) info.setProperty(key, styleValue); else info[key] = styleValue; diff --git a/index.js b/index.js index eb529e2f..235e00c5 100644 --- a/index.js +++ b/index.js @@ -623,7 +623,7 @@ var hyperHTML = (function (global) { for (var _key in newValue) { var value = newValue[_key]; var styleValue = typeof value === 'number' && !IS_NON_DIMENSIONAL.test(_key) ? value + 'px' : value; - if (/^--/.test(_key)) info.setProperty(_key, styleValue);else info[_key] = styleValue; + if (!isSVG && /^--/.test(_key)) info.setProperty(_key, styleValue);else info[_key] = styleValue; } oldType = 'object'; if (isSVG) style.value = toStyle(oldValue = info);else oldValue = newValue; diff --git a/min.js b/min.js index f6068e99..fb6dd144 100644 --- a/min.js +++ b/min.js @@ -1,2 +1,2 @@ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){this.childNodes=e,this.length=e.length,this.first=e[0],this.last=e[this.length-1],this._=null}function r(){}function i(e){var t=Fe.get(this);return t&&t.template===Y(e)?a.apply(t.updates,arguments):o.apply(this,arguments),this}function o(e){e=Y(e);var t=Be.get(e)||u.call(this,e),n=U(this.ownerDocument,t.fragment),r=ze.create(n,t.paths);Fe.set(this,{template:e,updates:r}),a.apply(r,arguments),this.textContent="",this.appendChild(n)}function a(){for(var e=arguments.length,t=1;t\"'=]+",M="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",$="(?:=(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",_=new RegExp(M+L+$+"+)([ "+T+"]*/?>)","g"),D=new RegExp(M+L+$+"*)([ "+T+"]*/>)","g"),P=function(e,t){return R(e).createElement(t)},R=function(e){return e.ownerDocument||e},H=function(e){return R(e).createDocumentFragment()},W=function(e,t){return R(e).createTextNode(t)},z=H(document),F="append"in z,B="content"in P(document,"template");z.appendChild(W(z,"g")),z.appendChild(W(z,""));var Z=1===z.cloneNode(!0).childNodes.length,V="importNode"in document,G=F?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"+t+"",G(r,X.call(n.querySelectorAll(i)))}else n.innerHTML=t,G(r,X.call(n.childNodes));return r},ne=B?function(e,t){var n=H(e),r=R(e).createElementNS(s,"svg");return r.innerHTML=t,G(n,X.call(r.childNodes)),n}:function(e,t){var n=H(e),r=P(e,"div");return r.innerHTML=''+t+"",G(n,X.call(r.firstChild.childNodes)),n};n.prototype.valueOf=function(e){var t=null==this._;return t&&(this._=H(this.first)),(t||e)&&G(this._,this.childNodes),this._},n.prototype.remove=function(){this._=null;var e=this.first,t=this.last;if(2===this.length)t.parentNode.removeChild(t);else{var n=R(e).createRange();n.setStartBefore(this.childNodes[1]),n.setEndAfter(t),n.deleteContents()}return e};var re=function(e){var t=[],n=void 0;switch(e.nodeType){case 1:case 11:n=e;break;case 8:n=e.parentNode,ie(t,n,e);break;default:n=e.ownerElement}for(e=n;n=n.parentNode;e=n)ie(t,n,e);return t},ie=function(e,t,n){e.unshift(e.indexOf.call(t.childNodes,n))},oe={create:function(e,t,n){return{type:e,name:n,node:t,path:re(t)}},find:function(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var g=Array(l),b=f[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},Ne=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,f=void 0,s=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],f=-l;f<=l;f+=2){for(d=f===-l||f!==l&&h[p+f-1]=0;l--){for(;d>0&&s>0&&a(r[i+d-1],e[t+s-1]);)m[g--]=0,d--,s--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],f=d-s,f===-l||f!==l&&h[p+f-1]>>0;n\"'=]+",M="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",$="(?:=(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",_=new RegExp(M+L+$+"+)([ "+T+"]*/?>)","g"),D=new RegExp(M+L+$+"*)([ "+T+"]*/>)","g"),P=function(e,t){return R(e).createElement(t)},R=function(e){return e.ownerDocument||e},H=function(e){return R(e).createDocumentFragment()},W=function(e,t){return R(e).createTextNode(t)},z=H(document),F="append"in z,B="content"in P(document,"template");z.appendChild(W(z,"g")),z.appendChild(W(z,""));var Z=1===z.cloneNode(!0).childNodes.length,V="importNode"in document,G=F?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"+t+"",G(r,X.call(n.querySelectorAll(i)))}else n.innerHTML=t,G(r,X.call(n.childNodes));return r},ne=B?function(e,t){var n=H(e),r=R(e).createElementNS(s,"svg");return r.innerHTML=t,G(n,X.call(r.childNodes)),n}:function(e,t){var n=H(e),r=P(e,"div");return r.innerHTML=''+t+"",G(n,X.call(r.firstChild.childNodes)),n};n.prototype.valueOf=function(e){var t=null==this._;return t&&(this._=H(this.first)),(t||e)&&G(this._,this.childNodes),this._},n.prototype.remove=function(){this._=null;var e=this.first,t=this.last;if(2===this.length)t.parentNode.removeChild(t);else{var n=R(e).createRange();n.setStartBefore(this.childNodes[1]),n.setEndAfter(t),n.deleteContents()}return e};var re=function(e){var t=[],n=void 0;switch(e.nodeType){case 1:case 11:n=e;break;case 8:n=e.parentNode,ie(t,n,e);break;default:n=e.ownerElement}for(e=n;n=n.parentNode;e=n)ie(t,n,e);return t},ie=function(e,t,n){e.unshift(e.indexOf.call(t.childNodes,n))},oe={create:function(e,t,n){return{type:e,name:n,node:t,path:re(t)}},find:function(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var g=Array(l),b=f[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},Ne=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,f=void 0,s=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],f=-l;f<=l;f+=2){for(d=f===-l||f!==l&&h[p+f-1]=0;l--){for(;d>0&&s>0&&a(r[i+d-1],e[t+s-1]);)m[g--]=0,d--,s--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],f=d-s,f===-l||f!==l&&h[p+f-1]>>0;n"},Ge=new b,Ie=function(e,t){return null==e?qe(t||"html"):Je(e,t||"html")},qe=function(e){var t=void 0,n=void 0,r=void 0,o=void 0,a=void 0;return function(u){u=Y(u);var c=o!==u;return c&&(o=u,r=H(document),n="svg"===e?document.createElementNS(s,"svg"):r,a=i.bind(n)),a.apply(null,arguments),c&&("svg"===e&&G(r,X.call(n.childNodes)),t=Ke(r)),t}},Je=function(e,t){var n=t.indexOf(":"),r=Ge.get(e),i=t;return-1\"'=]+",M="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",$="(?:=(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",_=new RegExp(M+L+$+"+)([ "+T+"]*/?>)","g"),D=new RegExp(M+L+$+"*)([ "+T+"]*/>)","g"),P=function(e,t){return R(e).createElement(t)},R=function(e){return e.ownerDocument||e},H=function(e){return R(e).createDocumentFragment()},W=function(e,t){return R(e).createTextNode(t)},z=H(document),F="append"in z,B="content"in P(document,"template");z.appendChild(W(z,"g")),z.appendChild(W(z,""));var Z=1===z.cloneNode(!0).childNodes.length,V="importNode"in document,G=F?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"+t+"",G(r,X.call(n.querySelectorAll(i)))}else n.innerHTML=t,G(r,X.call(n.childNodes));return r},ne=B?function(e,t){var n=H(e),r=R(e).createElementNS(s,"svg");return r.innerHTML=t,G(n,X.call(r.childNodes)),n}:function(e,t){var n=H(e),r=P(e,"div");return r.innerHTML=''+t+"",G(n,X.call(r.firstChild.childNodes)),n};n.prototype.valueOf=function(e){var t=null==this._;return t&&(this._=H(this.first)),(t||e)&&G(this._,this.childNodes),this._},n.prototype.remove=function(){this._=null;var e=this.first,t=this.last;if(2===this.length)t.parentNode.removeChild(t);else{var n=R(e).createRange();n.setStartBefore(this.childNodes[1]),n.setEndAfter(t),n.deleteContents()}return e};var re=function(e){var t=[],n=void 0;switch(e.nodeType){case 1:case 11:n=e;break;case 8:n=e.parentNode,ie(t,n,e);break;default:n=e.ownerElement}for(e=n;n=n.parentNode;e=n)ie(t,n,e);return t},ie=function(e,t,n){e.unshift(e.indexOf.call(t.childNodes,n))},oe={create:function(e,t,n){return{type:e,name:n,node:t,path:re(t)}},find:function(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var g=Array(l),b=f[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},Ne=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,f=void 0,s=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],f=-l;f<=l;f+=2){for(d=f===-l||f!==l&&h[p+f-1]=0;l--){for(;d>0&&s>0&&a(r[i+d-1],e[t+s-1]);)m[g--]=0,d--,s--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],f=d-s,f===-l||f!==l&&h[p+f-1]>>0;n\"'=]+",M="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",$="(?:=(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",_=new RegExp(M+L+$+"+)([ "+T+"]*/?>)","g"),D=new RegExp(M+L+$+"*)([ "+T+"]*/>)","g"),P=function(e,t){return R(e).createElement(t)},R=function(e){return e.ownerDocument||e},H=function(e){return R(e).createDocumentFragment()},W=function(e,t){return R(e).createTextNode(t)},z=H(document),F="append"in z,B="content"in P(document,"template");z.appendChild(W(z,"g")),z.appendChild(W(z,""));var Z=1===z.cloneNode(!0).childNodes.length,V="importNode"in document,G=F?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"+t+"",G(r,X.call(n.querySelectorAll(i)))}else n.innerHTML=t,G(r,X.call(n.childNodes));return r},ne=B?function(e,t){var n=H(e),r=R(e).createElementNS(s,"svg");return r.innerHTML=t,G(n,X.call(r.childNodes)),n}:function(e,t){var n=H(e),r=P(e,"div");return r.innerHTML=''+t+"",G(n,X.call(r.firstChild.childNodes)),n};n.prototype.valueOf=function(e){var t=null==this._;return t&&(this._=H(this.first)),(t||e)&&G(this._,this.childNodes),this._},n.prototype.remove=function(){this._=null;var e=this.first,t=this.last;if(2===this.length)t.parentNode.removeChild(t);else{var n=R(e).createRange();n.setStartBefore(this.childNodes[1]),n.setEndAfter(t),n.deleteContents()}return e};var re=function(e){var t=[],n=void 0;switch(e.nodeType){case 1:case 11:n=e;break;case 8:n=e.parentNode,ie(t,n,e);break;default:n=e.ownerElement}for(e=n;n=n.parentNode;e=n)ie(t,n,e);return t},ie=function(e,t,n){e.unshift(e.indexOf.call(t.childNodes,n))},oe={create:function(e,t,n){return{type:e,name:n,node:t,path:re(t)}},find:function(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var g=Array(l),b=f[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},Ne=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,f=void 0,s=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],f=-l;f<=l;f+=2){for(d=f===-l||f!==l&&h[p+f-1]=0;l--){for(;d>0&&s>0&&a(r[i+d-1],e[t+s-1]);)m[g--]=0,d--,s--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],f=d-s,f===-l||f!==l&&h[p+f-1]>>0;n"},Ge=new b,Ie=function(e,t){return null==e?qe(t||"html"):Je(e,t||"html")},qe=function(e){var t=void 0,n=void 0,r=void 0,o=void 0,a=void 0;return function(u){u=Y(u);var c=o!==u;return c&&(o=u,r=H(document),n="svg"===e?document.createElementNS(s,"svg"):r,a=i.bind(n)),a.apply(null,arguments),c&&("svg"===e&&G(r,X.call(n.childNodes)),t=Ke(r)),t}},Je=function(e,t){var n=t.indexOf(":"),r=Ge.get(e),i=t;return-1 Date: Wed, 21 Nov 2018 13:52:06 +0100 Subject: [PATCH 002/151] 2.17.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 970598d5..641c20b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hyperhtml", - "version": "2.17.0", + "version": "2.17.1", "description": "A Fast & Light Virtual DOM Alternative", "homepage": "https://viperhtml.js.org/hyper.html", "unpkg": "min.js", From 91b1db84b6c52550f30a2e9cb7a283bd159a0b83 Mon Sep 17 00:00:00 2001 From: Andrea Giammarchi Date: Thu, 22 Nov 2018 08:48:46 +0100 Subject: [PATCH 003/151] updated domdiff to latest --- cjs/3rd/utils.js | 12 ++++++------ esm.js | 2 +- esm/3rd/utils.js | 12 ++++++------ index.js | 14 +++++++------- min.js | 2 +- package.json | 2 +- umd.js | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/cjs/3rd/utils.js b/cjs/3rd/utils.js index 483aea85..63cc0722 100644 --- a/cjs/3rd/utils.js +++ b/cjs/3rd/utils.js @@ -104,11 +104,11 @@ const Rel = typeof Map === 'undefined' ? function () { const k = [], v = []; return { - has: value => -1 < k.indexOf(value), - get: value => v[k.indexOf(value)], - set: value => { - const i = k.indexOf(value); - v[i < 0 ? (k.push(value) - 1) : i] = value; + has: key => -1 < k.indexOf(key), + get: key => v[k.indexOf(key)], + set: (key, value) => { + const i = k.indexOf(key); + v[i < 0 ? (k.push(key) - 1) : i] = value; } }; } : @@ -339,7 +339,7 @@ const findK = (ktr, length, j) => { let lo = 1; let hi = length; while (lo < hi) { - var mid = ((lo + hi) / 2) >>> 0; + const mid = ((lo + hi) / 2) >>> 0; if (j < ktr[mid]) hi = mid; else diff --git a/esm.js b/esm.js index 5d6265fe..800f1b13 100644 --- a/esm.js +++ b/esm.js @@ -1,4 +1,4 @@ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){this.childNodes=e,this.length=e.length,this.first=e[0],this.last=e[this.length-1],this._=null}function r(){}function i(e){var t=Fe.get(this);return t&&t.template===Y(e)?a.apply(t.updates,arguments):o.apply(this,arguments),this}function o(e){e=Y(e);var t=Be.get(e)||u.call(this,e),n=U(this.ownerDocument,t.fragment),r=ze.create(n,t.paths);Fe.set(this,{template:e,updates:r}),a.apply(r,arguments),this.textContent="",this.appendChild(n)}function a(){for(var e=arguments.length,t=1;t\"'=]+",M="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",$="(?:=(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",_=new RegExp(M+L+$+"+)([ "+T+"]*/?>)","g"),D=new RegExp(M+L+$+"*)([ "+T+"]*/>)","g"),P=function(e,t){return R(e).createElement(t)},R=function(e){return e.ownerDocument||e},H=function(e){return R(e).createDocumentFragment()},W=function(e,t){return R(e).createTextNode(t)},z=H(document),F="append"in z,B="content"in P(document,"template");z.appendChild(W(z,"g")),z.appendChild(W(z,""));var Z=1===z.cloneNode(!0).childNodes.length,V="importNode"in document,G=F?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"+t+"",G(r,X.call(n.querySelectorAll(i)))}else n.innerHTML=t,G(r,X.call(n.childNodes));return r},ne=B?function(e,t){var n=H(e),r=R(e).createElementNS(s,"svg");return r.innerHTML=t,G(n,X.call(r.childNodes)),n}:function(e,t){var n=H(e),r=P(e,"div");return r.innerHTML=''+t+"",G(n,X.call(r.firstChild.childNodes)),n};n.prototype.valueOf=function(e){var t=null==this._;return t&&(this._=H(this.first)),(t||e)&&G(this._,this.childNodes),this._},n.prototype.remove=function(){this._=null;var e=this.first,t=this.last;if(2===this.length)t.parentNode.removeChild(t);else{var n=R(e).createRange();n.setStartBefore(this.childNodes[1]),n.setEndAfter(t),n.deleteContents()}return e};var re=function(e){var t=[],n=void 0;switch(e.nodeType){case 1:case 11:n=e;break;case 8:n=e.parentNode,ie(t,n,e);break;default:n=e.ownerElement}for(e=n;n=n.parentNode;e=n)ie(t,n,e);return t},ie=function(e,t,n){e.unshift(e.indexOf.call(t.childNodes,n))},oe={create:function(e,t,n){return{type:e,name:n,node:t,path:re(t)}},find:function(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var g=Array(l),b=f[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},Ne=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,f=void 0,s=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],f=-l;f<=l;f+=2){for(d=f===-l||f!==l&&h[p+f-1]=0;l--){for(;d>0&&s>0&&a(r[i+d-1],e[t+s-1]);)m[g--]=0,d--,s--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],f=d-s,f===-l||f!==l&&h[p+f-1]>>0;n\"'=]+",M="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",$="(?:=(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",_=new RegExp(M+L+$+"+)([ "+T+"]*/?>)","g"),D=new RegExp(M+L+$+"*)([ "+T+"]*/>)","g"),P=function(e,t){return R(e).createElement(t)},R=function(e){return e.ownerDocument||e},H=function(e){return R(e).createDocumentFragment()},W=function(e,t){return R(e).createTextNode(t)},z=H(document),F="append"in z,B="content"in P(document,"template");z.appendChild(W(z,"g")),z.appendChild(W(z,""));var Z=1===z.cloneNode(!0).childNodes.length,V="importNode"in document,G=F?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"+t+"",G(r,X.call(n.querySelectorAll(i)))}else n.innerHTML=t,G(r,X.call(n.childNodes));return r},ne=B?function(e,t){var n=H(e),r=R(e).createElementNS(s,"svg");return r.innerHTML=t,G(n,X.call(r.childNodes)),n}:function(e,t){var n=H(e),r=P(e,"div");return r.innerHTML=''+t+"",G(n,X.call(r.firstChild.childNodes)),n};n.prototype.valueOf=function(e){var t=null==this._;return t&&(this._=H(this.first)),(t||e)&&G(this._,this.childNodes),this._},n.prototype.remove=function(){this._=null;var e=this.first,t=this.last;if(2===this.length)t.parentNode.removeChild(t);else{var n=R(e).createRange();n.setStartBefore(this.childNodes[1]),n.setEndAfter(t),n.deleteContents()}return e};var re=function(e){var t=[],n=void 0;switch(e.nodeType){case 1:case 11:n=e;break;case 8:n=e.parentNode,ie(t,n,e);break;default:n=e.ownerElement}for(e=n;n=n.parentNode;e=n)ie(t,n,e);return t},ie=function(e,t,n){e.unshift(e.indexOf.call(t.childNodes,n))},oe={create:function(e,t,n){return{type:e,name:n,node:t,path:re(t)}},find:function(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var g=Array(l),b=f[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},Ne=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,f=void 0,s=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],f=-l;f<=l;f+=2){for(d=f===-l||f!==l&&h[p+f-1]=0;l--){for(;d>0&&s>0&&a(r[i+d-1],e[t+s-1]);)m[g--]=0,d--,s--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],f=d-s,f===-l||f!==l&&h[p+f-1]>>0;n"},Ge=new b,Ie=function(e,t){return null==e?qe(t||"html"):Je(e,t||"html")},qe=function(e){var t=void 0,n=void 0,r=void 0,o=void 0,a=void 0;return function(u){u=Y(u);var c=o!==u;return c&&(o=u,r=H(document),n="svg"===e?document.createElementNS(s,"svg"):r,a=i.bind(n)),a.apply(null,arguments),c&&("svg"===e&&G(r,X.call(n.childNodes)),t=Ke(r)),t}},Je=function(e,t){var n=t.indexOf(":"),r=Ge.get(e),i=t;return-1 -1 < k.indexOf(value), - get: value => v[k.indexOf(value)], - set: value => { - const i = k.indexOf(value); - v[i < 0 ? (k.push(value) - 1) : i] = value; + has: key => -1 < k.indexOf(key), + get: key => v[k.indexOf(key)], + set: (key, value) => { + const i = k.indexOf(key); + v[i < 0 ? (k.push(key) - 1) : i] = value; } }; } : @@ -331,7 +331,7 @@ const findK = (ktr, length, j) => { let lo = 1; let hi = length; while (lo < hi) { - var mid = ((lo + hi) / 2) >>> 0; + const mid = ((lo + hi) / 2) >>> 0; if (j < ktr[mid]) hi = mid; else diff --git a/index.js b/index.js index 235e00c5..70c05e86 100644 --- a/index.js +++ b/index.js @@ -721,15 +721,15 @@ var hyperHTML = (function (global) { var k = [], v = []; return { - has: function has(value) { - return -1 < k.indexOf(value); + has: function has(key) { + return -1 < k.indexOf(key); }, - get: function get(value) { - return v[k.indexOf(value)]; + get: function get(key) { + return v[k.indexOf(key)]; }, - set: function set(value) { - var i = k.indexOf(value); - v[i < 0 ? k.push(value) - 1 : i] = value; + set: function set(key, value) { + var i = k.indexOf(key); + v[i < 0 ? k.push(key) - 1 : i] = value; } }; } : Map; diff --git a/min.js b/min.js index fb6dd144..ee9dc0d9 100644 --- a/min.js +++ b/min.js @@ -1,2 +1,2 @@ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){this.childNodes=e,this.length=e.length,this.first=e[0],this.last=e[this.length-1],this._=null}function r(){}function i(e){var t=Fe.get(this);return t&&t.template===Y(e)?a.apply(t.updates,arguments):o.apply(this,arguments),this}function o(e){e=Y(e);var t=Be.get(e)||u.call(this,e),n=U(this.ownerDocument,t.fragment),r=ze.create(n,t.paths);Fe.set(this,{template:e,updates:r}),a.apply(r,arguments),this.textContent="",this.appendChild(n)}function a(){for(var e=arguments.length,t=1;t\"'=]+",M="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",$="(?:=(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",_=new RegExp(M+L+$+"+)([ "+T+"]*/?>)","g"),D=new RegExp(M+L+$+"*)([ "+T+"]*/>)","g"),P=function(e,t){return R(e).createElement(t)},R=function(e){return e.ownerDocument||e},H=function(e){return R(e).createDocumentFragment()},W=function(e,t){return R(e).createTextNode(t)},z=H(document),F="append"in z,B="content"in P(document,"template");z.appendChild(W(z,"g")),z.appendChild(W(z,""));var Z=1===z.cloneNode(!0).childNodes.length,V="importNode"in document,G=F?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"+t+"",G(r,X.call(n.querySelectorAll(i)))}else n.innerHTML=t,G(r,X.call(n.childNodes));return r},ne=B?function(e,t){var n=H(e),r=R(e).createElementNS(s,"svg");return r.innerHTML=t,G(n,X.call(r.childNodes)),n}:function(e,t){var n=H(e),r=P(e,"div");return r.innerHTML=''+t+"",G(n,X.call(r.firstChild.childNodes)),n};n.prototype.valueOf=function(e){var t=null==this._;return t&&(this._=H(this.first)),(t||e)&&G(this._,this.childNodes),this._},n.prototype.remove=function(){this._=null;var e=this.first,t=this.last;if(2===this.length)t.parentNode.removeChild(t);else{var n=R(e).createRange();n.setStartBefore(this.childNodes[1]),n.setEndAfter(t),n.deleteContents()}return e};var re=function(e){var t=[],n=void 0;switch(e.nodeType){case 1:case 11:n=e;break;case 8:n=e.parentNode,ie(t,n,e);break;default:n=e.ownerElement}for(e=n;n=n.parentNode;e=n)ie(t,n,e);return t},ie=function(e,t,n){e.unshift(e.indexOf.call(t.childNodes,n))},oe={create:function(e,t,n){return{type:e,name:n,node:t,path:re(t)}},find:function(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var g=Array(l),b=f[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},Ne=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,f=void 0,s=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],f=-l;f<=l;f+=2){for(d=f===-l||f!==l&&h[p+f-1]=0;l--){for(;d>0&&s>0&&a(r[i+d-1],e[t+s-1]);)m[g--]=0,d--,s--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],f=d-s,f===-l||f!==l&&h[p+f-1]>>0;n\"'=]+",M="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",$="(?:=(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",_=new RegExp(M+L+$+"+)([ "+T+"]*/?>)","g"),D=new RegExp(M+L+$+"*)([ "+T+"]*/>)","g"),P=function(e,t){return R(e).createElement(t)},R=function(e){return e.ownerDocument||e},H=function(e){return R(e).createDocumentFragment()},W=function(e,t){return R(e).createTextNode(t)},z=H(document),F="append"in z,B="content"in P(document,"template");z.appendChild(W(z,"g")),z.appendChild(W(z,""));var Z=1===z.cloneNode(!0).childNodes.length,V="importNode"in document,G=F?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"+t+"",G(r,X.call(n.querySelectorAll(i)))}else n.innerHTML=t,G(r,X.call(n.childNodes));return r},ne=B?function(e,t){var n=H(e),r=R(e).createElementNS(s,"svg");return r.innerHTML=t,G(n,X.call(r.childNodes)),n}:function(e,t){var n=H(e),r=P(e,"div");return r.innerHTML=''+t+"",G(n,X.call(r.firstChild.childNodes)),n};n.prototype.valueOf=function(e){var t=null==this._;return t&&(this._=H(this.first)),(t||e)&&G(this._,this.childNodes),this._},n.prototype.remove=function(){this._=null;var e=this.first,t=this.last;if(2===this.length)t.parentNode.removeChild(t);else{var n=R(e).createRange();n.setStartBefore(this.childNodes[1]),n.setEndAfter(t),n.deleteContents()}return e};var re=function(e){var t=[],n=void 0;switch(e.nodeType){case 1:case 11:n=e;break;case 8:n=e.parentNode,ie(t,n,e);break;default:n=e.ownerElement}for(e=n;n=n.parentNode;e=n)ie(t,n,e);return t},ie=function(e,t,n){e.unshift(e.indexOf.call(t.childNodes,n))},oe={create:function(e,t,n){return{type:e,name:n,node:t,path:re(t)}},find:function(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var g=Array(l),b=f[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},Ne=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,f=void 0,s=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],f=-l;f<=l;f+=2){for(d=f===-l||f!==l&&h[p+f-1]=0;l--){for(;d>0&&s>0&&a(r[i+d-1],e[t+s-1]);)m[g--]=0,d--,s--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],f=d-s,f===-l||f!==l&&h[p+f-1]>>0;n"},Ge=new b,Ie=function(e,t){return null==e?qe(t||"html"):Je(e,t||"html")},qe=function(e){var t=void 0,n=void 0,r=void 0,o=void 0,a=void 0;return function(u){u=Y(u);var c=o!==u;return c&&(o=u,r=H(document),n="svg"===e?document.createElementNS(s,"svg"):r,a=i.bind(n)),a.apply(null,arguments),c&&("svg"===e&&G(r,X.call(n.childNodes)),t=Ke(r)),t}},Je=function(e,t){var n=t.indexOf(":"),r=Ge.get(e),i=t;return-1\"'=]+",M="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",$="(?:=(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",_=new RegExp(M+L+$+"+)([ "+T+"]*/?>)","g"),D=new RegExp(M+L+$+"*)([ "+T+"]*/>)","g"),P=function(e,t){return R(e).createElement(t)},R=function(e){return e.ownerDocument||e},H=function(e){return R(e).createDocumentFragment()},W=function(e,t){return R(e).createTextNode(t)},z=H(document),F="append"in z,B="content"in P(document,"template");z.appendChild(W(z,"g")),z.appendChild(W(z,""));var Z=1===z.cloneNode(!0).childNodes.length,V="importNode"in document,G=F?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"+t+"",G(r,X.call(n.querySelectorAll(i)))}else n.innerHTML=t,G(r,X.call(n.childNodes));return r},ne=B?function(e,t){var n=H(e),r=R(e).createElementNS(s,"svg");return r.innerHTML=t,G(n,X.call(r.childNodes)),n}:function(e,t){var n=H(e),r=P(e,"div");return r.innerHTML=''+t+"",G(n,X.call(r.firstChild.childNodes)),n};n.prototype.valueOf=function(e){var t=null==this._;return t&&(this._=H(this.first)),(t||e)&&G(this._,this.childNodes),this._},n.prototype.remove=function(){this._=null;var e=this.first,t=this.last;if(2===this.length)t.parentNode.removeChild(t);else{var n=R(e).createRange();n.setStartBefore(this.childNodes[1]),n.setEndAfter(t),n.deleteContents()}return e};var re=function(e){var t=[],n=void 0;switch(e.nodeType){case 1:case 11:n=e;break;case 8:n=e.parentNode,ie(t,n,e);break;default:n=e.ownerElement}for(e=n;n=n.parentNode;e=n)ie(t,n,e);return t},ie=function(e,t,n){e.unshift(e.indexOf.call(t.childNodes,n))},oe={create:function(e,t,n){return{type:e,name:n,node:t,path:re(t)}},find:function(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var g=Array(l),b=f[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},Ne=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,f=void 0,s=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],f=-l;f<=l;f+=2){for(d=f===-l||f!==l&&h[p+f-1]=0;l--){for(;d>0&&s>0&&a(r[i+d-1],e[t+s-1]);)m[g--]=0,d--,s--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],f=d-s,f===-l||f!==l&&h[p+f-1]>>0;n\"'=]+",M="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",$="(?:=(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",_=new RegExp(M+L+$+"+)([ "+T+"]*/?>)","g"),D=new RegExp(M+L+$+"*)([ "+T+"]*/>)","g"),P=function(e,t){return R(e).createElement(t)},R=function(e){return e.ownerDocument||e},H=function(e){return R(e).createDocumentFragment()},W=function(e,t){return R(e).createTextNode(t)},z=H(document),F="append"in z,B="content"in P(document,"template");z.appendChild(W(z,"g")),z.appendChild(W(z,""));var Z=1===z.cloneNode(!0).childNodes.length,V="importNode"in document,G=F?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"+t+"",G(r,X.call(n.querySelectorAll(i)))}else n.innerHTML=t,G(r,X.call(n.childNodes));return r},ne=B?function(e,t){var n=H(e),r=R(e).createElementNS(s,"svg");return r.innerHTML=t,G(n,X.call(r.childNodes)),n}:function(e,t){var n=H(e),r=P(e,"div");return r.innerHTML=''+t+"",G(n,X.call(r.firstChild.childNodes)),n};n.prototype.valueOf=function(e){var t=null==this._;return t&&(this._=H(this.first)),(t||e)&&G(this._,this.childNodes),this._},n.prototype.remove=function(){this._=null;var e=this.first,t=this.last;if(2===this.length)t.parentNode.removeChild(t);else{var n=R(e).createRange();n.setStartBefore(this.childNodes[1]),n.setEndAfter(t),n.deleteContents()}return e};var re=function(e){var t=[],n=void 0;switch(e.nodeType){case 1:case 11:n=e;break;case 8:n=e.parentNode,ie(t,n,e);break;default:n=e.ownerElement}for(e=n;n=n.parentNode;e=n)ie(t,n,e);return t},ie=function(e,t,n){e.unshift(e.indexOf.call(t.childNodes,n))},oe={create:function(e,t,n){return{type:e,name:n,node:t,path:re(t)}},find:function(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var g=Array(l),b=f[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},Ne=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,f=void 0,s=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],f=-l;f<=l;f+=2){for(d=f===-l||f!==l&&h[p+f-1]=0;l--){for(;d>0&&s>0&&a(r[i+d-1],e[t+s-1]);)m[g--]=0,d--,s--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],f=d-s,f===-l||f!==l&&h[p+f-1]>>0;n"},Ge=new b,Ie=function(e,t){return null==e?qe(t||"html"):Je(e,t||"html")},qe=function(e){var t=void 0,n=void 0,r=void 0,o=void 0,a=void 0;return function(u){u=Y(u);var c=o!==u;return c&&(o=u,r=H(document),n="svg"===e?document.createElementNS(s,"svg"):r,a=i.bind(n)),a.apply(null,arguments),c&&("svg"===e&&G(r,X.call(n.childNodes)),t=Ke(r)),t}},Je=function(e,t){var n=t.indexOf(":"),r=Ge.get(e),i=t;return-1 Date: Thu, 22 Nov 2018 08:48:56 +0100 Subject: [PATCH 004/151] 2.17.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 24e553a0..1a017d58 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hyperhtml", - "version": "2.17.1", + "version": "2.17.2", "description": "A Fast & Light Virtual DOM Alternative", "homepage": "https://viperhtml.js.org/hyper.html", "unpkg": "min.js", From 07edc78abe2c85be056cda22567d03d5be976898 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Fri, 23 Nov 2018 12:48:38 +0000 Subject: [PATCH 005/151] chore(package): update domdiff to version 2.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1a017d58..2c3535a1 100644 --- a/package.json +++ b/package.json @@ -143,7 +143,7 @@ "basichtml": "^0.20.0", "coveralls": "^3.0.2", "disconnected": "^0.1.2", - "domdiff": "^1.0.2", + "domdiff": "^2.0.2", "istanbul": "^0.4.5", "npm-dollar": "^1.0.1", "rollup": "^0.67.0", From 91e55be77a1e93611194b49f2166d093b173c8a1 Mon Sep 17 00:00:00 2001 From: Andrea Giammarchi Date: Fri, 23 Nov 2018 14:44:26 +0100 Subject: [PATCH 006/151] Using @ungap modules instead of local solutions --- cjs/3rd/disconnected.js | 110 -- cjs/3rd/domdiff.js | 223 ----- cjs/3rd/utils.js | 396 -------- cjs/classes/Component.js | 4 +- cjs/hyper/render.js | 3 +- cjs/hyper/wire.js | 4 +- cjs/index.d.ts | 3 - cjs/index.js | 5 +- cjs/objects/Updates.js | 13 +- cjs/shared/domdiff.js | 223 ----- cjs/shared/poorlyfills.js | 74 -- cjs/shared/utils.js | 5 +- esm.js | 5 +- esm/3rd/disconnected.js | 109 -- esm/3rd/domdiff.js | 224 ----- esm/3rd/utils.js | 387 -------- esm/classes/Component.js | 4 +- esm/hyper/render.js | 3 +- esm/hyper/wire.js | 4 +- esm/index.js | 5 +- esm/objects/Updates.js | 13 +- esm/shared/poorlyfills.js | 68 -- esm/shared/utils.js | 5 +- index.js | 1981 +++++++++++++++++++------------------ min.js | 5 +- package.json | 13 +- rollup.config.js | 6 + test/ie/test/test.js | 22 +- test/runner.js | 2 - test/test.js | 32 +- umd.js | 5 +- 31 files changed, 1121 insertions(+), 2835 deletions(-) delete mode 100644 cjs/3rd/disconnected.js delete mode 100644 cjs/3rd/domdiff.js delete mode 100644 cjs/3rd/utils.js delete mode 100644 cjs/index.d.ts delete mode 100644 cjs/shared/domdiff.js delete mode 100644 cjs/shared/poorlyfills.js delete mode 100644 esm/3rd/disconnected.js delete mode 100644 esm/3rd/domdiff.js delete mode 100644 esm/3rd/utils.js delete mode 100644 esm/shared/poorlyfills.js diff --git a/cjs/3rd/disconnected.js b/cjs/3rd/disconnected.js deleted file mode 100644 index 611103de..00000000 --- a/cjs/3rd/disconnected.js +++ /dev/null @@ -1,110 +0,0 @@ -'use strict'; -/* AUTOMATICALLY IMPORTED, DO NOT MODIFY */ -/*! (c) Andrea Giammarchi */ -function disconnected(poly) {'use strict'; - var CONNECTED = 'connected'; - var DISCONNECTED = 'dis' + CONNECTED; - var Event = poly.Event; - var WeakSet = poly.WeakSet; - var notObserving = true; - var observer = new WeakSet; - return function observe(node) { - if (notObserving) { - notObserving = !notObserving; - startObserving(node.ownerDocument); - } - observer.add(node); - return node; - }; - function startObserving(document) { - var dispatched = null; - try { - (new MutationObserver(changes)).observe( - document, - {subtree: true, childList: true} - ); - } - catch(o_O) { - var timer = 0; - var records = []; - var reschedule = function (record) { - records.push(record); - clearTimeout(timer); - timer = setTimeout( - function () { - changes(records.splice(timer = 0, records.length)); - }, - 0 - ); - }; - document.addEventListener( - 'DOMNodeRemoved', - function (event) { - reschedule({addedNodes: [], removedNodes: [event.target]}); - }, - true - ); - document.addEventListener( - 'DOMNodeInserted', - function (event) { - reschedule({addedNodes: [event.target], removedNodes: []}); - }, - true - ); - } - function changes(records) { - dispatched = new Tracker; - for (var - record, - length = records.length, - i = 0; i < length; i++ - ) { - record = records[i]; - dispatchAll(record.removedNodes, DISCONNECTED, CONNECTED); - dispatchAll(record.addedNodes, CONNECTED, DISCONNECTED); - } - dispatched = null; - } - function dispatchAll(nodes, type, counter) { - for (var - node, - event = new Event(type), - length = nodes.length, - i = 0; i < length; - (node = nodes[i++]).nodeType === 1 && - dispatchTarget(node, event, type, counter) - ); - } - function dispatchTarget(node, event, type, counter) { - if (observer.has(node) && !dispatched[type].has(node)) { - dispatched[counter].delete(node); - dispatched[type].add(node); - node.dispatchEvent(event); - /* - // The event is not bubbling (perf reason: should it?), - // hence there's no way to know if - // stop/Immediate/Propagation() was called. - // Should DOM Level 0 work at all? - // I say it's a YAGNI case for the time being, - // and easy to implement in user-land. - if (!event.cancelBubble) { - var fn = node['on' + type]; - if (fn) - fn.call(node, event); - } - */ - } - for (var - children = node.children, - length = children.length, - i = 0; i < length; - dispatchTarget(children[i++], event, type, counter) - ); - } - function Tracker() { - this[CONNECTED] = new WeakSet; - this[DISCONNECTED] = new WeakSet; - } - } -} -Object.defineProperty(exports, '__esModule', {value: true}).default = disconnected; diff --git a/cjs/3rd/domdiff.js b/cjs/3rd/domdiff.js deleted file mode 100644 index 67b3b079..00000000 --- a/cjs/3rd/domdiff.js +++ /dev/null @@ -1,223 +0,0 @@ -'use strict'; -/* AUTOMATICALLY IMPORTED, DO NOT MODIFY */ -/*! (c) 2018 Andrea Giammarchi (ISC) */ - -const { - eqeq, identity, indexOf, isReversed, next, append, remove, smartDiff -} = require('./utils.js'); - -const domdiff = ( - parentNode, // where changes happen - currentNodes, // Array of current items/nodes - futureNodes, // Array of future items/nodes - options // optional object with one of the following properties - // before: domNode - // compare(generic, generic) => true if same generic - // node(generic) => Node -) => { - if (!options) - options = {}; - - const compare = options.compare || eqeq; - const get = options.node || identity; - const before = options.before == null ? null : get(options.before, 0); - - const currentLength = currentNodes.length; - let currentEnd = currentLength; - let currentStart = 0; - - let futureEnd = futureNodes.length; - let futureStart = 0; - - // common prefix - while ( - currentStart < currentEnd && - futureStart < futureEnd && - compare(currentNodes[currentStart], futureNodes[futureStart]) - ) { - currentStart++; - futureStart++; - } - - // common suffix - while ( - currentStart < currentEnd && - futureStart < futureEnd && - compare(currentNodes[currentEnd - 1], futureNodes[futureEnd - 1]) - ) { - currentEnd--; - futureEnd--; - } - - const currentSame = currentStart === currentEnd; - const futureSame = futureStart === futureEnd; - - // same list - if (currentSame && futureSame) - return futureNodes; - - // only stuff to add - if (currentSame && futureStart < futureEnd) { - append( - get, - parentNode, - futureNodes, - futureStart, - futureEnd, - next(get, currentNodes, currentStart, currentLength, before) - ); - return futureNodes; - } - - // only stuff to remove - if (futureSame && currentStart < currentEnd) { - remove( - get, - parentNode, - currentNodes, - currentStart, - currentEnd - ); - return futureNodes; - } - - const currentChanges = currentEnd - currentStart; - const futureChanges = futureEnd - futureStart; - let i = -1; - - // 2 simple indels: the shortest sequence is a subsequence of the longest - if (currentChanges < futureChanges) { - i = indexOf( - futureNodes, - futureStart, - futureEnd, - currentNodes, - currentStart, - currentEnd, - compare - ); - // inner diff - if (-1 < i) { - append( - get, - parentNode, - futureNodes, - futureStart, - i, - get(currentNodes[currentStart], 0) - ); - append( - get, - parentNode, - futureNodes, - i + currentChanges, - futureEnd, - next(get, currentNodes, currentEnd, currentLength, before) - ); - return futureNodes; - } - } - /* istanbul ignore else */ - else if (futureChanges < currentChanges) { - i = indexOf( - currentNodes, - currentStart, - currentEnd, - futureNodes, - futureStart, - futureEnd, - compare - ); - // outer diff - if (-1 < i) { - remove( - get, - parentNode, - currentNodes, - currentStart, - i - ); - remove( - get, - parentNode, - currentNodes, - i + futureChanges, - currentEnd - ); - return futureNodes; - } - } - - // common case with one replacement for many nodes - // or many nodes replaced for a single one - /* istanbul ignore else */ - if ((currentChanges < 2 || futureChanges < 2)) { - append( - get, - parentNode, - futureNodes, - futureStart, - futureEnd, - get(currentNodes[currentStart], 0) - ); - remove( - get, - parentNode, - currentNodes, - currentStart, - currentEnd - ); - return futureNodes; - } - - // the half match diff part has been skipped in petit-dom - // https://github.com/yelouafi/petit-dom/blob/bd6f5c919b5ae5297be01612c524c40be45f14a7/src/vdom.js#L391-L397 - // accordingly, I think it's safe to skip in here too - // if one day it'll come out like the speediest thing ever to do - // then I might add it in here too - - // Extra: before going too fancy, what about reversed lists ? - // This should bail out pretty quickly if that's not the case. - if ( - currentChanges === futureChanges && - isReversed( - futureNodes, - futureEnd, - currentNodes, - currentStart, - currentEnd, - compare - ) - ) { - append( - get, - parentNode, - futureNodes, - futureStart, - futureEnd, - next(get, currentNodes, currentEnd, currentLength, before) - ); - return futureNodes; - } - - // last resort through a smart diff - smartDiff( - get, - parentNode, - futureNodes, - futureStart, - futureEnd, - futureChanges, - currentNodes, - currentStart, - currentEnd, - currentChanges, - currentLength, - compare, - before - ); - - return futureNodes; -}; - -Object.defineProperty(exports, '__esModule', {value: true}).default = domdiff; diff --git a/cjs/3rd/utils.js b/cjs/3rd/utils.js deleted file mode 100644 index 63cc0722..00000000 --- a/cjs/3rd/utils.js +++ /dev/null @@ -1,396 +0,0 @@ -'use strict'; -/* AUTOMATICALLY IMPORTED, DO NOT MODIFY */ -const append = (get, parent, children, start, end, before) => { - if ((end - start) < 2) - parent.insertBefore(get(children[start], 1), before); - else { - const fragment = parent.ownerDocument.createDocumentFragment(); - while (start < end) - fragment.appendChild(get(children[start++], 1)); - parent.insertBefore(fragment, before); - } -}; -exports.append = append; - -const eqeq = (a, b) => a == b; -exports.eqeq = eqeq; - -const identity = O => O; -exports.identity = identity; - -const indexOf = ( - moreNodes, - moreStart, - moreEnd, - lessNodes, - lessStart, - lessEnd, - compare -) => { - const length = lessEnd - lessStart; - /* istanbul ignore if */ - if (length < 1) - return -1; - while ((moreEnd - moreStart) >= length) { - let m = moreStart; - let l = lessStart; - while ( - m < moreEnd && - l < lessEnd && - compare(moreNodes[m], lessNodes[l]) - ) { - m++; - l++; - } - if (l === lessEnd) - return moreStart; - moreStart = m + 1; - } - return -1; -}; -exports.indexOf = indexOf; - -const isReversed = ( - futureNodes, - futureEnd, - currentNodes, - currentStart, - currentEnd, - compare -) => { - while ( - currentStart < currentEnd && - compare( - currentNodes[currentStart], - futureNodes[futureEnd - 1] - )) { - currentStart++; - futureEnd--; - }; - return futureEnd === 0; -}; -exports.isReversed = isReversed; - -const next = (get, list, i, length, before) => i < length ? - get(list[i], 0) : - (0 < i ? - get(list[i - 1], -0).nextSibling : - before); -exports.next = next; - -const remove = (get, parent, children, start, end) => { - if ((end - start) < 2) - parent.removeChild(get(children[start], -1)); - else { - const range = parent.ownerDocument.createRange(); - range.setStartBefore(get(children[start], -1)); - range.setEndAfter(get(children[end - 1], -1)); - range.deleteContents(); - } -}; -exports.remove = remove; - -// - - - - - - - - - - - - - - - - - - - -// diff related constants and utilities -// - - - - - - - - - - - - - - - - - - - - -const DELETION = -1; -const INSERTION = 1; -const SKIP = 0; -const SKIP_OND = 50; - -/* istanbul ignore next */ -const Rel = typeof Map === 'undefined' ? - function () { - const k = [], v = []; - return { - has: key => -1 < k.indexOf(key), - get: key => v[k.indexOf(key)], - set: (key, value) => { - const i = k.indexOf(key); - v[i < 0 ? (k.push(key) - 1) : i] = value; - } - }; - } : - Map -; - -const HS = ( - futureNodes, - futureStart, - futureEnd, - futureChanges, - currentNodes, - currentStart, - currentEnd, - currentChanges -) => { - - let k = 0; - /* istanbul ignore next */ - let minLen = futureChanges < currentChanges ? futureChanges : currentChanges; - const link = Array(minLen++); - const tresh = Array(minLen); - tresh[0] = -1; - - for (let i = 1; i < minLen; i++) - tresh[i] = currentEnd; - - const keymap = new Rel; - for (let i = currentStart; i < currentEnd; i++) - keymap.set(currentNodes[i], i); - - for (let i = futureStart; i < futureEnd; i++) { - const idxInOld = keymap.get(futureNodes[i]); - if (idxInOld != null) { - k = findK(tresh, minLen, idxInOld); - /* istanbul ignore else */ - if (-1 < k) { - tresh[k] = idxInOld; - link[k] = { - newi: i, - oldi: idxInOld, - prev: link[k - 1] - }; - } - } - } - - k = --minLen; - --currentEnd; - while (tresh[k] > currentEnd) --k; - - minLen = currentChanges + futureChanges - k; - const diff = Array(minLen); - let ptr = link[k]; - --futureEnd; - while (ptr) { - const {newi, oldi} = ptr; - while (futureEnd > newi) { - diff[--minLen] = INSERTION; - --futureEnd; - } - while (currentEnd > oldi) { - diff[--minLen] = DELETION; - --currentEnd; - } - diff[--minLen] = SKIP; - --futureEnd; - --currentEnd; - ptr = ptr.prev; - } - while (futureEnd >= futureStart) { - diff[--minLen] = INSERTION; - --futureEnd; - } - while (currentEnd >= currentStart) { - diff[--minLen] = DELETION; - --currentEnd; - } - return diff; -}; - -// this is pretty much the same petit-dom code without the delete map part -// https://github.com/yelouafi/petit-dom/blob/bd6f5c919b5ae5297be01612c524c40be45f14a7/src/vdom.js#L556-L561 -const OND = ( - futureNodes, - futureStart, - rows, - currentNodes, - currentStart, - cols, - compare -) => { - const length = rows + cols; - const v = []; - let d, k, r, c, pv, cv, pd; - outer: for (d = 0; d <= length; d++) { - /* istanbul ignore if */ - if (d > SKIP_OND) - return null; - pd = d - 1; - /* istanbul ignore next */ - pv = d ? v[d - 1] : [0, 0]; - cv = v[d] = []; - for (k = -d; k <= d; k += 2) { - if (k === -d || (k !== d && pv[pd + k - 1] < pv[pd + k + 1])) { - c = pv[pd + k + 1]; - } else { - c = pv[pd + k - 1] + 1; - } - r = c - k; - while ( - c < cols && - r < rows && - compare( - currentNodes[currentStart + c], - futureNodes[futureStart + r] - ) - ) { - c++; - r++; - } - if (c === cols && r === rows) { - break outer; - } - cv[d + k] = c; - } - } - - const diff = Array(d / 2 + length / 2); - let diffIdx = diff.length - 1; - for (d = v.length - 1; d >= 0; d--) { - while ( - c > 0 && - r > 0 && - compare( - currentNodes[currentStart + c - 1], - futureNodes[futureStart + r - 1] - ) - ) { - // diagonal edge = equality - diff[diffIdx--] = SKIP; - c--; - r--; - } - if (!d) - break; - pd = d - 1; - /* istanbul ignore next */ - pv = d ? v[d - 1] : [0, 0]; - k = c - r; - if (k === -d || (k !== d && pv[pd + k - 1] < pv[pd + k + 1])) { - // vertical edge = insertion - r--; - diff[diffIdx--] = INSERTION; - } else { - // horizontal edge = deletion - c--; - diff[diffIdx--] = DELETION; - } - } - return diff; -}; - -const applyDiff = ( - diff, - get, - parentNode, - futureNodes, - futureStart, - currentNodes, - currentStart, - currentLength, - before -) => { - const live = new Rel; - const length = diff.length; - let currentIndex = currentStart; - let i = 0; - while (i < length) { - switch (diff[i++]) { - case SKIP: - futureStart++; - currentIndex++; - break; - case INSERTION: - // TODO: bulk appends for sequential nodes - live.set(futureNodes[futureStart], 1); - append( - get, - parentNode, - futureNodes, - futureStart++, - futureStart, - currentIndex < currentLength ? - get(currentNodes[currentIndex], 1) : - before - ); - break; - case DELETION: - currentIndex++; - break; - } - } - i = 0; - while (i < length) { - switch (diff[i++]) { - case SKIP: - currentStart++; - break; - case DELETION: - // TODO: bulk removes for sequential nodes - if (live.has(currentNodes[currentStart])) - currentStart++; - else - remove( - get, - parentNode, - currentNodes, - currentStart++, - currentStart - ); - break; - } - } -}; - -const findK = (ktr, length, j) => { - let lo = 1; - let hi = length; - while (lo < hi) { - const mid = ((lo + hi) / 2) >>> 0; - if (j < ktr[mid]) - hi = mid; - else - lo = mid + 1; - } - return lo; -} - -const smartDiff = ( - get, - parentNode, - futureNodes, - futureStart, - futureEnd, - futureChanges, - currentNodes, - currentStart, - currentEnd, - currentChanges, - currentLength, - compare, - before -) => { - applyDiff( - OND( - futureNodes, - futureStart, - futureChanges, - currentNodes, - currentStart, - currentChanges, - compare - ) || - HS( - futureNodes, - futureStart, - futureEnd, - futureChanges, - currentNodes, - currentStart, - currentEnd, - currentChanges - ), - get, - parentNode, - futureNodes, - futureStart, - currentNodes, - currentStart, - currentLength, - before - ); -}; -exports.smartDiff = smartDiff; diff --git a/cjs/classes/Component.js b/cjs/classes/Component.js index 1667e96d..7e5c299c 100644 --- a/cjs/classes/Component.js +++ b/cjs/classes/Component.js @@ -1,5 +1,7 @@ 'use strict'; -const { Map, WeakMap } = require('../shared/poorlyfills.js'); +const CustomEvent = (m => m.__esModule ? m.default : m)(require('@ungap/custom-event')); +const Map = (m => m.__esModule ? m.default : m)(require('@ungap/essential-map')); +const WeakMap = (m => m.__esModule ? m.default : m)(require('@ungap/weakmap')); // hyperHTML.Component is a very basic class // able to create Custom Elements like components diff --git a/cjs/hyper/render.js b/cjs/hyper/render.js index 9b8a4faf..d457ef9b 100644 --- a/cjs/hyper/render.js +++ b/cjs/hyper/render.js @@ -1,5 +1,6 @@ 'use strict'; -const {WeakMap} = require('../shared/poorlyfills.js'); +const WeakMap = (m => m.__esModule ? m.default : m)(require('@ungap/weakmap')); + const {UIDC, VOID_ELEMENTS} = require('../shared/constants.js'); const Updates = (m => m.__esModule ? m.default : m)(require('../objects/Updates.js')); const { diff --git a/cjs/hyper/wire.js b/cjs/hyper/wire.js index be8eefa5..9ec20815 100644 --- a/cjs/hyper/wire.js +++ b/cjs/hyper/wire.js @@ -1,6 +1,8 @@ 'use strict'; +const WeakMap = (m => m.__esModule ? m.default : m)(require('@ungap/weakmap')); +const trim = (m => m.__esModule ? m.default : m)(require('@ungap/trim')); + const {ELEMENT_NODE, SVG_NAMESPACE} = require('../shared/constants.js'); -const {WeakMap, trim} = require('../shared/poorlyfills.js'); const {fragment} = require('../shared/easy-dom.js'); const {append, slice, unique} = require('../shared/utils.js'); const Wire = (m => m.__esModule ? m.default : m)(require('../classes/Wire.js')); diff --git a/cjs/index.d.ts b/cjs/index.d.ts deleted file mode 100644 index 02ce463a..00000000 --- a/cjs/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import hyper from ".."; -export * from '..'; -export default hyper; diff --git a/cjs/index.js b/cjs/index.js index e742253d..182e154d 100644 --- a/cjs/index.js +++ b/cjs/index.js @@ -1,6 +1,9 @@ 'use strict'; /*! (c) Andrea Giammarchi (ISC) */ +const WeakMap = (m => m.__esModule ? m.default : m)(require('@ungap/weakmap')); +const WeakSet = (m => m.__esModule ? m.default : m)(require('@ungap/essential-weakset')); +const diff = (m => m.__esModule ? m.default : m)(require('domdiff')); const Component = (m => m.__esModule ? m.default : m)(require('./classes/Component.js')); const {setup} = require('./classes/Component.js'); const Intent = (m => m.__esModule ? m.default : m)(require('./objects/Intent.js')); @@ -8,8 +11,6 @@ const {observe} = require('./objects/Updates.js'); const wire = (m => m.__esModule ? m.default : m)(require('./hyper/wire.js')); const {content, weakly} = require('./hyper/wire.js'); const render = (m => m.__esModule ? m.default : m)(require('./hyper/render.js')); -const diff = (m => m.__esModule ? m.default : m)(require('./3rd/domdiff.js')); -const { WeakMap, WeakSet } = require('./shared/poorlyfills.js'); const { G } = require('./shared/constants.js'); // all functions are self bound to the right context diff --git a/cjs/objects/Updates.js b/cjs/objects/Updates.js index f4a55cea..853ac657 100644 --- a/cjs/objects/Updates.js +++ b/cjs/objects/Updates.js @@ -1,4 +1,12 @@ 'use strict'; +const CustomEvent = (m => m.__esModule ? m.default : m)(require('@ungap/custom-event')); +const WeakSet = (m => m.__esModule ? m.default : m)(require('@ungap/essential-weakset')); +const isArray = (m => m.__esModule ? m.default : m)(require('@ungap/is-array')); +const trim = (m => m.__esModule ? m.default : m)(require('@ungap/trim')); + +const disconnected = (m => m.__esModule ? m.default : m)(require('disconnected')); +const domdiff = (m => m.__esModule ? m.default : m)(require('domdiff')); + const { CONNECTED, DISCONNECTED, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, ELEMENT_NODE, TEXT_NODE, OWNER_SVG_ELEMENT, SHOULD_USE_TEXT_CONTENT, G, UID, UIDC } = require('../shared/constants.js'); @@ -8,16 +16,13 @@ const Wire = (m => m.__esModule ? m.default : m)(require('../classes/Wire.js')); const Path = (m => m.__esModule ? m.default : m)(require('./Path.js')); const Style = (m => m.__esModule ? m.default : m)(require('./Style.js')); const Intent = (m => m.__esModule ? m.default : m)(require('./Intent.js')); -const domdiff = (m => m.__esModule ? m.default : m)(require('../3rd/domdiff.js')); // see /^script$/i.test(nodeName) bit down here // import { create as createElement, text } from '../shared/easy-dom.js'; const { text } = require('../shared/easy-dom.js'); -const { Event, WeakSet, isArray, trim } = require('../shared/poorlyfills.js'); const { createFragment, slice } = require('../shared/utils.js'); -const disconnected = (m => m.__esModule ? m.default : m)(require('../3rd/disconnected.js')); const { document } = G; -const observe = disconnected({Event, WeakSet}); +const observe = disconnected({Event: CustomEvent, WeakSet}); // a basic dictionary used to filter already cached attributes // while looking for special hyperHTML values. diff --git a/cjs/shared/domdiff.js b/cjs/shared/domdiff.js deleted file mode 100644 index 67b3b079..00000000 --- a/cjs/shared/domdiff.js +++ /dev/null @@ -1,223 +0,0 @@ -'use strict'; -/* AUTOMATICALLY IMPORTED, DO NOT MODIFY */ -/*! (c) 2018 Andrea Giammarchi (ISC) */ - -const { - eqeq, identity, indexOf, isReversed, next, append, remove, smartDiff -} = require('./utils.js'); - -const domdiff = ( - parentNode, // where changes happen - currentNodes, // Array of current items/nodes - futureNodes, // Array of future items/nodes - options // optional object with one of the following properties - // before: domNode - // compare(generic, generic) => true if same generic - // node(generic) => Node -) => { - if (!options) - options = {}; - - const compare = options.compare || eqeq; - const get = options.node || identity; - const before = options.before == null ? null : get(options.before, 0); - - const currentLength = currentNodes.length; - let currentEnd = currentLength; - let currentStart = 0; - - let futureEnd = futureNodes.length; - let futureStart = 0; - - // common prefix - while ( - currentStart < currentEnd && - futureStart < futureEnd && - compare(currentNodes[currentStart], futureNodes[futureStart]) - ) { - currentStart++; - futureStart++; - } - - // common suffix - while ( - currentStart < currentEnd && - futureStart < futureEnd && - compare(currentNodes[currentEnd - 1], futureNodes[futureEnd - 1]) - ) { - currentEnd--; - futureEnd--; - } - - const currentSame = currentStart === currentEnd; - const futureSame = futureStart === futureEnd; - - // same list - if (currentSame && futureSame) - return futureNodes; - - // only stuff to add - if (currentSame && futureStart < futureEnd) { - append( - get, - parentNode, - futureNodes, - futureStart, - futureEnd, - next(get, currentNodes, currentStart, currentLength, before) - ); - return futureNodes; - } - - // only stuff to remove - if (futureSame && currentStart < currentEnd) { - remove( - get, - parentNode, - currentNodes, - currentStart, - currentEnd - ); - return futureNodes; - } - - const currentChanges = currentEnd - currentStart; - const futureChanges = futureEnd - futureStart; - let i = -1; - - // 2 simple indels: the shortest sequence is a subsequence of the longest - if (currentChanges < futureChanges) { - i = indexOf( - futureNodes, - futureStart, - futureEnd, - currentNodes, - currentStart, - currentEnd, - compare - ); - // inner diff - if (-1 < i) { - append( - get, - parentNode, - futureNodes, - futureStart, - i, - get(currentNodes[currentStart], 0) - ); - append( - get, - parentNode, - futureNodes, - i + currentChanges, - futureEnd, - next(get, currentNodes, currentEnd, currentLength, before) - ); - return futureNodes; - } - } - /* istanbul ignore else */ - else if (futureChanges < currentChanges) { - i = indexOf( - currentNodes, - currentStart, - currentEnd, - futureNodes, - futureStart, - futureEnd, - compare - ); - // outer diff - if (-1 < i) { - remove( - get, - parentNode, - currentNodes, - currentStart, - i - ); - remove( - get, - parentNode, - currentNodes, - i + futureChanges, - currentEnd - ); - return futureNodes; - } - } - - // common case with one replacement for many nodes - // or many nodes replaced for a single one - /* istanbul ignore else */ - if ((currentChanges < 2 || futureChanges < 2)) { - append( - get, - parentNode, - futureNodes, - futureStart, - futureEnd, - get(currentNodes[currentStart], 0) - ); - remove( - get, - parentNode, - currentNodes, - currentStart, - currentEnd - ); - return futureNodes; - } - - // the half match diff part has been skipped in petit-dom - // https://github.com/yelouafi/petit-dom/blob/bd6f5c919b5ae5297be01612c524c40be45f14a7/src/vdom.js#L391-L397 - // accordingly, I think it's safe to skip in here too - // if one day it'll come out like the speediest thing ever to do - // then I might add it in here too - - // Extra: before going too fancy, what about reversed lists ? - // This should bail out pretty quickly if that's not the case. - if ( - currentChanges === futureChanges && - isReversed( - futureNodes, - futureEnd, - currentNodes, - currentStart, - currentEnd, - compare - ) - ) { - append( - get, - parentNode, - futureNodes, - futureStart, - futureEnd, - next(get, currentNodes, currentEnd, currentLength, before) - ); - return futureNodes; - } - - // last resort through a smart diff - smartDiff( - get, - parentNode, - futureNodes, - futureStart, - futureEnd, - futureChanges, - currentNodes, - currentStart, - currentEnd, - currentChanges, - currentLength, - compare, - before - ); - - return futureNodes; -}; - -Object.defineProperty(exports, '__esModule', {value: true}).default = domdiff; diff --git a/cjs/shared/poorlyfills.js b/cjs/shared/poorlyfills.js deleted file mode 100644 index a4f44b34..00000000 --- a/cjs/shared/poorlyfills.js +++ /dev/null @@ -1,74 +0,0 @@ -'use strict'; -const {G, UID} = require('./constants.js'); - -// you know that kind of basics you need to cover -// your use case only but you don't want to bloat the library? -// There's even a package in here: -// https://www.npmjs.com/package/poorlyfills - -// used to dispatch simple events -let Event = G.Event; -try { - new Event('Event'); -} catch(o_O) { - Event = function (type) { - const e = document.createEvent('Event'); - e.initEvent(type, false, false); - return e; - }; -} -exports.Event = Event; - -// used to store template literals -/* istanbul ignore next */ -const Map = G.Map || function Map() { - const keys = [], values = []; - return { - get(obj) { - return values[keys.indexOf(obj)]; - }, - set(obj, value) { - values[keys.push(obj) - 1] = value; - } - }; -}; -exports.Map = Map; - -// used to store wired content -let ID = 0; -const WeakMap = G.WeakMap || function WeakMap() { - const key = UID + ID++; - return { - delete(obj) { delete obj[key]; }, - get(obj) { return obj[key]; }, - set(obj, value) { - Object.defineProperty(obj, key, { - configurable: true, - value - }); - } - }; -}; -exports.WeakMap = WeakMap; - -// used to store hyper.Components -const WeakSet = G.WeakSet || function WeakSet() { - const wm = new WeakMap; - return { - delete(obj) { wm.delete(obj); }, - add(obj) { wm.set(obj, true); }, - has(obj) { return wm.get(obj) === true; } - }; -}; -exports.WeakSet = WeakSet; - -// used to be sure IE9 or older Androids work as expected -const isArray = Array.isArray || (toString => - arr => toString.call(arr) === '[object Array]' -)({}.toString); -exports.isArray = isArray; - -const trim = UID.trim || function () { - return this.replace(/^\s+|\s+$/g, ''); -}; -exports.trim = trim; diff --git a/cjs/shared/utils.js b/cjs/shared/utils.js index 2c02c0de..72ddddb3 100644 --- a/cjs/shared/utils.js +++ b/cjs/shared/utils.js @@ -1,4 +1,7 @@ 'use strict'; +const Map = (m => m.__esModule ? m.default : m)(require('@ungap/essential-map')); +const WeakMap = (m => m.__esModule ? m.default : m)(require('@ungap/weakmap')); + const {attrName, attrSeeker} = require('./re.js'); const { @@ -19,8 +22,6 @@ const { const {create, doc, fragment} = require('./easy-dom.js'); -const {Map, WeakMap} = require('./poorlyfills.js'); - // appends an array of nodes // to a generic node/fragment // When available, uses append passing all arguments at once diff --git a/esm.js b/esm.js index 800f1b13..b7f9af46 100644 --- a/esm.js +++ b/esm.js @@ -1,4 +1,5 @@ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){this.childNodes=e,this.length=e.length,this.first=e[0],this.last=e[this.length-1],this._=null}function r(){}function i(e){var t=Fe.get(this);return t&&t.template===Y(e)?a.apply(t.updates,arguments):o.apply(this,arguments),this}function o(e){e=Y(e);var t=Be.get(e)||u.call(this,e),n=U(this.ownerDocument,t.fragment),r=ze.create(n,t.paths);Fe.set(this,{template:e,updates:r}),a.apply(r,arguments),this.textContent="",this.appendChild(n)}function a(){for(var e=arguments.length,t=1;t\"'=]+",M="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",$="(?:=(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",_=new RegExp(M+L+$+"+)([ "+T+"]*/?>)","g"),D=new RegExp(M+L+$+"*)([ "+T+"]*/>)","g"),P=function(e,t){return R(e).createElement(t)},R=function(e){return e.ownerDocument||e},H=function(e){return R(e).createDocumentFragment()},W=function(e,t){return R(e).createTextNode(t)},z=H(document),F="append"in z,B="content"in P(document,"template");z.appendChild(W(z,"g")),z.appendChild(W(z,""));var Z=1===z.cloneNode(!0).childNodes.length,V="importNode"in document,G=F?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"+t+"",G(r,X.call(n.querySelectorAll(i)))}else n.innerHTML=t,G(r,X.call(n.childNodes));return r},ne=B?function(e,t){var n=H(e),r=R(e).createElementNS(s,"svg");return r.innerHTML=t,G(n,X.call(r.childNodes)),n}:function(e,t){var n=H(e),r=P(e,"div");return r.innerHTML=''+t+"",G(n,X.call(r.firstChild.childNodes)),n};n.prototype.valueOf=function(e){var t=null==this._;return t&&(this._=H(this.first)),(t||e)&&G(this._,this.childNodes),this._},n.prototype.remove=function(){this._=null;var e=this.first,t=this.last;if(2===this.length)t.parentNode.removeChild(t);else{var n=R(e).createRange();n.setStartBefore(this.childNodes[1]),n.setEndAfter(t),n.deleteContents()}return e};var re=function(e){var t=[],n=void 0;switch(e.nodeType){case 1:case 11:n=e;break;case 8:n=e.parentNode,ie(t,n,e);break;default:n=e.ownerElement}for(e=n;n=n.parentNode;e=n)ie(t,n,e);return t},ie=function(e,t,n){e.unshift(e.indexOf.call(t.childNodes,n))},oe={create:function(e,t,n){return{type:e,name:n,node:t,path:re(t)}},find:function(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var g=Array(l),b=f[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},Ne=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,f=void 0,s=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],f=-l;f<=l;f+=2){for(d=f===-l||f!==l&&h[p+f-1]=0;l--){for(;d>0&&s>0&&a(r[i+d-1],e[t+s-1]);)m[g--]=0,d--,s--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],f=d-s,f===-l||f!==l&&h[p+f-1]>>0;n"},Ge=new b,Ie=function(e,t){return null==e?qe(t||"html"):Je(e,t||"html")},qe=function(e){var t=void 0,n=void 0,r=void 0,o=void 0,a=void 0;return function(u){u=Y(u);var c=o!==u;return c&&(o=u,r=H(document),n="svg"===e?document.createElementNS(s,"svg"):r,a=i.bind(n)),a.apply(null,arguments),c&&("svg"===e&&G(r,X.call(n.childNodes)),t=Ke(r)),t}},Je=function(e,t){var n=t.indexOf(":"),r=Ge.get(e),i=t;return-1=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var b=Array(l),w=s[c];for(--n;w;){for(var y=w,N=y.newi,E=y.oldi;n>N;)b[--l]=1,--n;for(;a>E;)b[--l]=-1,--a;b[--l]=0,--n,--a,w=w.prev}for(;n>=t;)b[--l]=1,--n;for(;a>=o;)b[--l]=-1,--a;return b},k=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)m[g--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n\"'=]+",J="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",K="(?:=(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",Q=new RegExp(J+q+K+"+)([ "+I+"]*/?>)","g"),U=new RegExp(J+q+K+"*)([ "+I+"]*/>)","g"),X=function(e,t){return Y(e).createElement(t)},Y=function(e){return e.ownerDocument||e},ee=function(e){return Y(e).createDocumentFragment()},te=function(e,t){return Y(e).createTextNode(t)},ne=ee(document),re="append"in ne,ie="content"in X(document,"template");ne.appendChild(te(ne,"g")),ne.appendChild(te(ne,""));var oe=1===ne.cloneNode(!0).childNodes.length,ae="importNode"in document,ue=re?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"+t+"",ue(r,ve.call(n.querySelectorAll(i)))}else n.innerHTML=t,ue(r,ve.call(n.childNodes));return r},be=ie?function(e,t){var n=ee(e),r=Y(e).createElementNS(B,"svg");return r.innerHTML=t,ue(n,ve.call(r.childNodes)),n}:function(e,t){var n=ee(e),r=X(e,"div");return r.innerHTML=''+t+"",ue(n,ve.call(r.firstChild.childNodes)),n};n.prototype.valueOf=function(e){var t=null==this._;return t&&(this._=ee(this.first)),(t||e)&&ue(this._,this.childNodes),this._},n.prototype.remove=function(){this._=null;var e=this.first,t=this.last;if(2===this.length)t.parentNode.removeChild(t);else{var n=Y(e).createRange();n.setStartBefore(this.childNodes[1]),n.setEndAfter(t),n.deleteContents()}return e};var we=function(e){var t=[],n=void 0;switch(e.nodeType){case 1:case 11:n=e;break;case 8:n=e.parentNode,ye(t,n,e);break;default:n=e.ownerElement}for(e=n;n=n.parentNode;e=n)ye(t,n,e);return t},ye=function(e,t,n){e.unshift(e.indexOf.call(t.childNodes,n))},Ne={create:function(e,t,n){return{type:e,name:n,node:t,path:we(t)}},find:function(e,t){for(var n=t.length,r=0;r"},qe=new s,Je=function(e,t){return null==e?Ke(t||"html"):Qe(e,t||"html")},Ke=function(e){var t=void 0,n=void 0,r=void 0,o=void 0,a=void 0;return function(u){u=pe(u);var c=o!==u;return c&&(o=u,r=ee(document),n="svg"===e?document.createElementNS(B,"svg"):r,a=i.bind(n)),a.apply(null,arguments),c&&("svg"===e&&ue(r,ve.call(n.childNodes)),t=Ue(r)),t}},Qe=function(e,t){var n=t.indexOf(":"),r=qe.get(e),i=t;return-1 true if same generic - // node(generic) => Node -) => { - if (!options) - options = {}; - - const compare = options.compare || eqeq; - const get = options.node || identity; - const before = options.before == null ? null : get(options.before, 0); - - const currentLength = currentNodes.length; - let currentEnd = currentLength; - let currentStart = 0; - - let futureEnd = futureNodes.length; - let futureStart = 0; - - // common prefix - while ( - currentStart < currentEnd && - futureStart < futureEnd && - compare(currentNodes[currentStart], futureNodes[futureStart]) - ) { - currentStart++; - futureStart++; - } - - // common suffix - while ( - currentStart < currentEnd && - futureStart < futureEnd && - compare(currentNodes[currentEnd - 1], futureNodes[futureEnd - 1]) - ) { - currentEnd--; - futureEnd--; - } - - const currentSame = currentStart === currentEnd; - const futureSame = futureStart === futureEnd; - - // same list - if (currentSame && futureSame) - return futureNodes; - - // only stuff to add - if (currentSame && futureStart < futureEnd) { - append( - get, - parentNode, - futureNodes, - futureStart, - futureEnd, - next(get, currentNodes, currentStart, currentLength, before) - ); - return futureNodes; - } - - // only stuff to remove - if (futureSame && currentStart < currentEnd) { - remove( - get, - parentNode, - currentNodes, - currentStart, - currentEnd - ); - return futureNodes; - } - - const currentChanges = currentEnd - currentStart; - const futureChanges = futureEnd - futureStart; - let i = -1; - - // 2 simple indels: the shortest sequence is a subsequence of the longest - if (currentChanges < futureChanges) { - i = indexOf( - futureNodes, - futureStart, - futureEnd, - currentNodes, - currentStart, - currentEnd, - compare - ); - // inner diff - if (-1 < i) { - append( - get, - parentNode, - futureNodes, - futureStart, - i, - get(currentNodes[currentStart], 0) - ); - append( - get, - parentNode, - futureNodes, - i + currentChanges, - futureEnd, - next(get, currentNodes, currentEnd, currentLength, before) - ); - return futureNodes; - } - } - /* istanbul ignore else */ - else if (futureChanges < currentChanges) { - i = indexOf( - currentNodes, - currentStart, - currentEnd, - futureNodes, - futureStart, - futureEnd, - compare - ); - // outer diff - if (-1 < i) { - remove( - get, - parentNode, - currentNodes, - currentStart, - i - ); - remove( - get, - parentNode, - currentNodes, - i + futureChanges, - currentEnd - ); - return futureNodes; - } - } - - // common case with one replacement for many nodes - // or many nodes replaced for a single one - /* istanbul ignore else */ - if ((currentChanges < 2 || futureChanges < 2)) { - append( - get, - parentNode, - futureNodes, - futureStart, - futureEnd, - get(currentNodes[currentStart], 0) - ); - remove( - get, - parentNode, - currentNodes, - currentStart, - currentEnd - ); - return futureNodes; - } - - // the half match diff part has been skipped in petit-dom - // https://github.com/yelouafi/petit-dom/blob/bd6f5c919b5ae5297be01612c524c40be45f14a7/src/vdom.js#L391-L397 - // accordingly, I think it's safe to skip in here too - // if one day it'll come out like the speediest thing ever to do - // then I might add it in here too - - // Extra: before going too fancy, what about reversed lists ? - // This should bail out pretty quickly if that's not the case. - if ( - currentChanges === futureChanges && - isReversed( - futureNodes, - futureEnd, - currentNodes, - currentStart, - currentEnd, - compare - ) - ) { - append( - get, - parentNode, - futureNodes, - futureStart, - futureEnd, - next(get, currentNodes, currentEnd, currentLength, before) - ); - return futureNodes; - } - - // last resort through a smart diff - smartDiff( - get, - parentNode, - futureNodes, - futureStart, - futureEnd, - futureChanges, - currentNodes, - currentStart, - currentEnd, - currentChanges, - currentLength, - compare, - before - ); - - return futureNodes; -}; - -export default domdiff; diff --git a/esm/3rd/utils.js b/esm/3rd/utils.js deleted file mode 100644 index ec6cdd82..00000000 --- a/esm/3rd/utils.js +++ /dev/null @@ -1,387 +0,0 @@ -/* AUTOMATICALLY IMPORTED, DO NOT MODIFY */ -export const append = (get, parent, children, start, end, before) => { - if ((end - start) < 2) - parent.insertBefore(get(children[start], 1), before); - else { - const fragment = parent.ownerDocument.createDocumentFragment(); - while (start < end) - fragment.appendChild(get(children[start++], 1)); - parent.insertBefore(fragment, before); - } -}; - -export const eqeq = (a, b) => a == b; - -export const identity = O => O; - -export const indexOf = ( - moreNodes, - moreStart, - moreEnd, - lessNodes, - lessStart, - lessEnd, - compare -) => { - const length = lessEnd - lessStart; - /* istanbul ignore if */ - if (length < 1) - return -1; - while ((moreEnd - moreStart) >= length) { - let m = moreStart; - let l = lessStart; - while ( - m < moreEnd && - l < lessEnd && - compare(moreNodes[m], lessNodes[l]) - ) { - m++; - l++; - } - if (l === lessEnd) - return moreStart; - moreStart = m + 1; - } - return -1; -}; - -export const isReversed = ( - futureNodes, - futureEnd, - currentNodes, - currentStart, - currentEnd, - compare -) => { - while ( - currentStart < currentEnd && - compare( - currentNodes[currentStart], - futureNodes[futureEnd - 1] - )) { - currentStart++; - futureEnd--; - }; - return futureEnd === 0; -}; - -export const next = (get, list, i, length, before) => i < length ? - get(list[i], 0) : - (0 < i ? - get(list[i - 1], -0).nextSibling : - before); - -export const remove = (get, parent, children, start, end) => { - if ((end - start) < 2) - parent.removeChild(get(children[start], -1)); - else { - const range = parent.ownerDocument.createRange(); - range.setStartBefore(get(children[start], -1)); - range.setEndAfter(get(children[end - 1], -1)); - range.deleteContents(); - } -}; - -// - - - - - - - - - - - - - - - - - - - -// diff related constants and utilities -// - - - - - - - - - - - - - - - - - - - - -const DELETION = -1; -const INSERTION = 1; -const SKIP = 0; -const SKIP_OND = 50; - -/* istanbul ignore next */ -const Rel = typeof Map === 'undefined' ? - function () { - const k = [], v = []; - return { - has: key => -1 < k.indexOf(key), - get: key => v[k.indexOf(key)], - set: (key, value) => { - const i = k.indexOf(key); - v[i < 0 ? (k.push(key) - 1) : i] = value; - } - }; - } : - Map -; - -const HS = ( - futureNodes, - futureStart, - futureEnd, - futureChanges, - currentNodes, - currentStart, - currentEnd, - currentChanges -) => { - - let k = 0; - /* istanbul ignore next */ - let minLen = futureChanges < currentChanges ? futureChanges : currentChanges; - const link = Array(minLen++); - const tresh = Array(minLen); - tresh[0] = -1; - - for (let i = 1; i < minLen; i++) - tresh[i] = currentEnd; - - const keymap = new Rel; - for (let i = currentStart; i < currentEnd; i++) - keymap.set(currentNodes[i], i); - - for (let i = futureStart; i < futureEnd; i++) { - const idxInOld = keymap.get(futureNodes[i]); - if (idxInOld != null) { - k = findK(tresh, minLen, idxInOld); - /* istanbul ignore else */ - if (-1 < k) { - tresh[k] = idxInOld; - link[k] = { - newi: i, - oldi: idxInOld, - prev: link[k - 1] - }; - } - } - } - - k = --minLen; - --currentEnd; - while (tresh[k] > currentEnd) --k; - - minLen = currentChanges + futureChanges - k; - const diff = Array(minLen); - let ptr = link[k]; - --futureEnd; - while (ptr) { - const {newi, oldi} = ptr; - while (futureEnd > newi) { - diff[--minLen] = INSERTION; - --futureEnd; - } - while (currentEnd > oldi) { - diff[--minLen] = DELETION; - --currentEnd; - } - diff[--minLen] = SKIP; - --futureEnd; - --currentEnd; - ptr = ptr.prev; - } - while (futureEnd >= futureStart) { - diff[--minLen] = INSERTION; - --futureEnd; - } - while (currentEnd >= currentStart) { - diff[--minLen] = DELETION; - --currentEnd; - } - return diff; -}; - -// this is pretty much the same petit-dom code without the delete map part -// https://github.com/yelouafi/petit-dom/blob/bd6f5c919b5ae5297be01612c524c40be45f14a7/src/vdom.js#L556-L561 -const OND = ( - futureNodes, - futureStart, - rows, - currentNodes, - currentStart, - cols, - compare -) => { - const length = rows + cols; - const v = []; - let d, k, r, c, pv, cv, pd; - outer: for (d = 0; d <= length; d++) { - /* istanbul ignore if */ - if (d > SKIP_OND) - return null; - pd = d - 1; - /* istanbul ignore next */ - pv = d ? v[d - 1] : [0, 0]; - cv = v[d] = []; - for (k = -d; k <= d; k += 2) { - if (k === -d || (k !== d && pv[pd + k - 1] < pv[pd + k + 1])) { - c = pv[pd + k + 1]; - } else { - c = pv[pd + k - 1] + 1; - } - r = c - k; - while ( - c < cols && - r < rows && - compare( - currentNodes[currentStart + c], - futureNodes[futureStart + r] - ) - ) { - c++; - r++; - } - if (c === cols && r === rows) { - break outer; - } - cv[d + k] = c; - } - } - - const diff = Array(d / 2 + length / 2); - let diffIdx = diff.length - 1; - for (d = v.length - 1; d >= 0; d--) { - while ( - c > 0 && - r > 0 && - compare( - currentNodes[currentStart + c - 1], - futureNodes[futureStart + r - 1] - ) - ) { - // diagonal edge = equality - diff[diffIdx--] = SKIP; - c--; - r--; - } - if (!d) - break; - pd = d - 1; - /* istanbul ignore next */ - pv = d ? v[d - 1] : [0, 0]; - k = c - r; - if (k === -d || (k !== d && pv[pd + k - 1] < pv[pd + k + 1])) { - // vertical edge = insertion - r--; - diff[diffIdx--] = INSERTION; - } else { - // horizontal edge = deletion - c--; - diff[diffIdx--] = DELETION; - } - } - return diff; -}; - -const applyDiff = ( - diff, - get, - parentNode, - futureNodes, - futureStart, - currentNodes, - currentStart, - currentLength, - before -) => { - const live = new Rel; - const length = diff.length; - let currentIndex = currentStart; - let i = 0; - while (i < length) { - switch (diff[i++]) { - case SKIP: - futureStart++; - currentIndex++; - break; - case INSERTION: - // TODO: bulk appends for sequential nodes - live.set(futureNodes[futureStart], 1); - append( - get, - parentNode, - futureNodes, - futureStart++, - futureStart, - currentIndex < currentLength ? - get(currentNodes[currentIndex], 1) : - before - ); - break; - case DELETION: - currentIndex++; - break; - } - } - i = 0; - while (i < length) { - switch (diff[i++]) { - case SKIP: - currentStart++; - break; - case DELETION: - // TODO: bulk removes for sequential nodes - if (live.has(currentNodes[currentStart])) - currentStart++; - else - remove( - get, - parentNode, - currentNodes, - currentStart++, - currentStart - ); - break; - } - } -}; - -const findK = (ktr, length, j) => { - let lo = 1; - let hi = length; - while (lo < hi) { - const mid = ((lo + hi) / 2) >>> 0; - if (j < ktr[mid]) - hi = mid; - else - lo = mid + 1; - } - return lo; -} - -export const smartDiff = ( - get, - parentNode, - futureNodes, - futureStart, - futureEnd, - futureChanges, - currentNodes, - currentStart, - currentEnd, - currentChanges, - currentLength, - compare, - before -) => { - applyDiff( - OND( - futureNodes, - futureStart, - futureChanges, - currentNodes, - currentStart, - currentChanges, - compare - ) || - HS( - futureNodes, - futureStart, - futureEnd, - futureChanges, - currentNodes, - currentStart, - currentEnd, - currentChanges - ), - get, - parentNode, - futureNodes, - futureStart, - currentNodes, - currentStart, - currentLength, - before - ); -}; diff --git a/esm/classes/Component.js b/esm/classes/Component.js index 04dc3fc2..ca73f2cb 100644 --- a/esm/classes/Component.js +++ b/esm/classes/Component.js @@ -1,4 +1,6 @@ -import { Map, WeakMap } from '../shared/poorlyfills.js'; +import CustomEvent from '@ungap/custom-event'; +import Map from '@ungap/essential-map'; +import WeakMap from '@ungap/weakmap'; // hyperHTML.Component is a very basic class // able to create Custom Elements like components diff --git a/esm/hyper/render.js b/esm/hyper/render.js index 05d27f30..6131cd1c 100644 --- a/esm/hyper/render.js +++ b/esm/hyper/render.js @@ -1,4 +1,5 @@ -import {WeakMap} from '../shared/poorlyfills.js'; +import WeakMap from '@ungap/weakmap'; + import {UIDC, VOID_ELEMENTS} from '../shared/constants.js'; import Updates from '../objects/Updates.js'; import { diff --git a/esm/hyper/wire.js b/esm/hyper/wire.js index 47b02a7c..fc41c91d 100644 --- a/esm/hyper/wire.js +++ b/esm/hyper/wire.js @@ -1,5 +1,7 @@ +import WeakMap from '@ungap/weakmap'; +import trim from '@ungap/trim'; + import {ELEMENT_NODE, SVG_NAMESPACE} from '../shared/constants.js'; -import {WeakMap, trim} from '../shared/poorlyfills.js'; import {fragment} from '../shared/easy-dom.js'; import {append, slice, unique} from '../shared/utils.js'; import Wire from '../classes/Wire.js'; diff --git a/esm/index.js b/esm/index.js index 013b4919..ec4b515d 100644 --- a/esm/index.js +++ b/esm/index.js @@ -1,12 +1,13 @@ /*! (c) Andrea Giammarchi (ISC) */ +import WeakMap from '@ungap/weakmap'; +import WeakSet from '@ungap/essential-weakset'; +import diff from 'domdiff'; import Component, {setup} from './classes/Component.js'; import Intent from './objects/Intent.js'; import {observe} from './objects/Updates.js'; import wire, {content, weakly} from './hyper/wire.js'; import render from './hyper/render.js'; -import diff from './3rd/domdiff.js'; -import { WeakMap, WeakSet } from './shared/poorlyfills.js'; import { G } from './shared/constants.js'; // all functions are self bound to the right context diff --git a/esm/objects/Updates.js b/esm/objects/Updates.js index 9ebb0f72..e494ded6 100644 --- a/esm/objects/Updates.js +++ b/esm/objects/Updates.js @@ -1,3 +1,11 @@ +import CustomEvent from '@ungap/custom-event'; +import WeakSet from '@ungap/essential-weakset'; +import isArray from '@ungap/is-array'; +import trim from '@ungap/trim'; + +import disconnected from 'disconnected'; +import domdiff from 'domdiff'; + import { CONNECTED, DISCONNECTED, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, ELEMENT_NODE, TEXT_NODE, @@ -11,16 +19,13 @@ import Wire from '../classes/Wire.js'; import Path from './Path.js'; import Style from './Style.js'; import Intent from './Intent.js'; -import domdiff from '../3rd/domdiff.js'; // see /^script$/i.test(nodeName) bit down here // import { create as createElement, text } from '../shared/easy-dom.js'; import { text } from '../shared/easy-dom.js'; -import { Event, WeakSet, isArray, trim } from '../shared/poorlyfills.js'; import { createFragment, slice } from '../shared/utils.js'; -import disconnected from '../3rd/disconnected.js'; const { document } = G; -const observe = disconnected({Event, WeakSet}); +const observe = disconnected({Event: CustomEvent, WeakSet}); // a basic dictionary used to filter already cached attributes // while looking for special hyperHTML values. diff --git a/esm/shared/poorlyfills.js b/esm/shared/poorlyfills.js deleted file mode 100644 index 4dcfaf27..00000000 --- a/esm/shared/poorlyfills.js +++ /dev/null @@ -1,68 +0,0 @@ -import {G, UID} from './constants.js'; - -// you know that kind of basics you need to cover -// your use case only but you don't want to bloat the library? -// There's even a package in here: -// https://www.npmjs.com/package/poorlyfills - -// used to dispatch simple events -let Event = G.Event; -try { - new Event('Event'); -} catch(o_O) { - Event = function (type) { - const e = document.createEvent('Event'); - e.initEvent(type, false, false); - return e; - }; -} -export {Event}; - -// used to store template literals -/* istanbul ignore next */ -export const Map = G.Map || function Map() { - const keys = [], values = []; - return { - get(obj) { - return values[keys.indexOf(obj)]; - }, - set(obj, value) { - values[keys.push(obj) - 1] = value; - } - }; -}; - -// used to store wired content -let ID = 0; -export const WeakMap = G.WeakMap || function WeakMap() { - const key = UID + ID++; - return { - delete(obj) { delete obj[key]; }, - get(obj) { return obj[key]; }, - set(obj, value) { - Object.defineProperty(obj, key, { - configurable: true, - value - }); - } - }; -}; - -// used to store hyper.Components -export const WeakSet = G.WeakSet || function WeakSet() { - const wm = new WeakMap; - return { - delete(obj) { wm.delete(obj); }, - add(obj) { wm.set(obj, true); }, - has(obj) { return wm.get(obj) === true; } - }; -}; - -// used to be sure IE9 or older Androids work as expected -export const isArray = Array.isArray || (toString => - arr => toString.call(arr) === '[object Array]' -)({}.toString); - -export const trim = UID.trim || function () { - return this.replace(/^\s+|\s+$/g, ''); -}; diff --git a/esm/shared/utils.js b/esm/shared/utils.js index 9eb368a9..079d8979 100644 --- a/esm/shared/utils.js +++ b/esm/shared/utils.js @@ -1,3 +1,6 @@ +import Map from '@ungap/essential-map'; +import WeakMap from '@ungap/weakmap'; + import {attrName, attrSeeker} from './re.js'; import { @@ -18,8 +21,6 @@ import { import {create, doc, fragment} from './easy-dom.js'; -import {Map, WeakMap} from './poorlyfills.js'; - // appends an array of nodes // to a generic node/fragment // When available, uses append passing all arguments at once diff --git a/index.js b/index.js index 70c05e86..3646a2af 100644 --- a/index.js +++ b/index.js @@ -1,1107 +1,1138 @@ var hyperHTML = (function (global) { 'use strict'; - var G = document.defaultView; - - // Node.CONSTANTS - // 'cause some engine has no global Node defined - // (i.e. Node, NativeScript, basicHTML ... ) - var ELEMENT_NODE = 1; - var TEXT_NODE = 3; - var COMMENT_NODE = 8; - var DOCUMENT_FRAGMENT_NODE = 11; - - // HTML related constants - var VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i; - - // SVG related constants - var OWNER_SVG_ELEMENT = 'ownerSVGElement'; - var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; - - // Custom Elements / MutationObserver constants - var CONNECTED = 'connected'; - var DISCONNECTED = 'dis' + CONNECTED; - - // hyperHTML related constants - var EXPANDO = '_hyper: '; - var SHOULD_USE_TEXT_CONTENT = /^(?:style|textarea)$/i; - var UID = EXPANDO + (Math.random() * new Date() | 0) + ';'; - var UIDC = ''; - - // you know that kind of basics you need to cover - // your use case only but you don't want to bloat the library? - // There's even a package in here: - // https://www.npmjs.com/package/poorlyfills - - // used to dispatch simple events - var Event = G.Event; + /*! (c) Andrea Giammarchi - ISC */ + var self = null || /* istanbul ignore next */{}; try { - new Event('Event'); - } catch (o_O) { - Event = function Event(type) { - var e = document.createEvent('Event'); - e.initEvent(type, false, false); - return e; - }; + self.WeakMap = WeakMap; + } catch (WeakMap) { + // this could be better but 90% of the time + // it's everything developers need as fallback + self.WeakMap = function (id, Object) { + + var dP = Object.defineProperty; + var hOP = Object.hasOwnProperty; + var proto = WeakMap.prototype; + proto.delete = function (key) { + return this.has(key) && delete key[this._]; + }; + proto.get = function (key) { + return this.has(key) ? key[this._] : void 0; + }; + proto.has = function (key) { + return hOP.call(key, this._); + }; + proto.set = function (key, value) { + dP(key, this._, { configurable: true, value: value }); + return this; + }; + return WeakMap; + function WeakMap(iterable) { + dP(this, '_', { value: '_@ungap/weakmap' + id++ }); + if (iterable) iterable.forEach(add, this); + } + function add(pair) { + this.set(pair[0], pair[1]); + } + }(Math.random(), Object); } + var WeakMap$1 = self.WeakMap; - // used to store template literals - /* istanbul ignore next */ - var Map$1 = G.Map || function Map() { - var keys = [], - values = []; - return { - get: function get(obj) { - return values[keys.indexOf(obj)]; - }, - set: function set(obj, value) { - values[keys.push(obj) - 1] = value; - } - }; - }; + /*! (c) Andrea Giammarchi - ISC */ + var self$1 = null || /* istanbul ignore next */{}; + try { + self$1.WeakSet = WeakSet; + } catch (WeakSet) { + (function (id, dP) { + var proto = WeakSet.prototype; + proto.add = function (object) { + if (!this.has(object)) dP(object, this._, { value: true, configurable: true }); + return this; + }; + proto.has = function (object) { + return this.hasOwnProperty.call(object, this._); + }; + proto.delete = function (object) { + return this.has(object) && delete object[this._]; + }; + self$1.WeakSet = WeakSet; + function WeakSet() { - // used to store wired content - var ID = 0; - var WeakMap = G.WeakMap || function WeakMap() { - var key = UID + ID++; - return { - delete: function _delete(obj) { - delete obj[key]; - }, - get: function get(obj) { - return obj[key]; - }, - set: function set(obj, value) { - Object.defineProperty(obj, key, { - configurable: true, - value: value - }); + dP(this, '_', { value: '_@ungap/weakmap' + id++ }); } - }; - }; + })(Math.random(), Object.defineProperty); + } + var WeakSet$1 = self$1.WeakSet; - // used to store hyper.Components - var WeakSet = G.WeakSet || function WeakSet() { - var wm = new WeakMap(); - return { - delete: function _delete(obj) { - wm.delete(obj); - }, - add: function add(obj) { - wm.set(obj, true); - }, - has: function has(obj) { - return wm.get(obj) === true; + /*! (c) Andrea Giammarchi - ISC */ + var self$2 = null || /* istanbul ignore next */{}; + try { + self$2.Map = Map; + } catch (Map) { + self$2.Map = function Map() { + var i = 0; + var k = []; + var v = []; + return { + delete: function _delete(key) { + var had = contains(key); + if (had) { + k.splice(i, 1); + v.splice(i, 1); + } + return had; + }, + get: function get(key) { + return contains(key) ? v[i] : void 0; + }, + has: function has(key) { + return contains(key); + }, + set: function set(key, value) { + v[contains(key) ? i : k.push(key) - 1] = value; + return this; + } + }; + function contains(v) { + i = k.indexOf(v); + return -1 < i; } }; - }; + } + var Map$1 = self$2.Map; - // used to be sure IE9 or older Androids work as expected - var isArray = Array.isArray || function (toString) { - return function (arr) { - return toString.call(arr) === '[object Array]'; - }; - }({}.toString); + var append = function append(get, parent, children, start, end, before) { + if (end - start < 2) parent.insertBefore(get(children[start], 1), before);else { + var fragment = parent.ownerDocument.createDocumentFragment(); + while (start < end) { + fragment.appendChild(get(children[start++], 1)); + }parent.insertBefore(fragment, before); + } + }; - var trim = UID.trim || function () { - return this.replace(/^\s+|\s+$/g, ''); + var eqeq = function eqeq(a, b) { + return a == b; }; - // hyperHTML.Component is a very basic class - // able to create Custom Elements like components - // including the ability to listen to connect/disconnect - // events via onconnect/ondisconnect attributes - // Components can be created imperatively or declaratively. - // The main difference is that declared components - // will not automatically render on setState(...) - // to simplify state handling on render. - function Component() { - return this; // this is needed in Edge !!! - } + var identity = function identity(O) { + return O; + }; - // Component is lazily setup because it needs - // wire mechanism as lazy content - function setup(content) { - // there are various weakly referenced variables in here - // and mostly are to use Component.for(...) static method. - var children = new WeakMap(); - var create = Object.create; - var createEntry = function createEntry(wm, id, component) { - wm.set(id, component); - return component; - }; - var get = function get(Class, info, context, id) { - var relation = info.get(Class) || relate(Class, info); - switch (typeof id) { - case 'object': - case 'function': - var wm = relation.w || (relation.w = new WeakMap()); - return wm.get(id) || createEntry(wm, id, new Class(context)); - default: - var sm = relation.p || (relation.p = create(null)); - return sm[id] || (sm[id] = new Class(context)); - } - }; - var relate = function relate(Class, info) { - var relation = { w: null, p: null }; - info.set(Class, relation); - return relation; - }; - var set = function set(context) { - var info = new Map$1(); - children.set(context, info); - return info; - }; - // The Component Class - Object.defineProperties(Component, { - // Component.for(context[, id]) is a convenient way - // to automatically relate data/context to children components - // If not created yet, the new Component(context) is weakly stored - // and after that same instance would always be returned. - for: { - configurable: true, - value: function value(context, id) { - return get(this, children.get(context) || set(context), context, id == null ? 'default' : id); - } + var indexOf = function indexOf(moreNodes, moreStart, moreEnd, lessNodes, lessStart, lessEnd, compare) { + var length = lessEnd - lessStart; + /* istanbul ignore if */ + if (length < 1) return -1; + while (moreEnd - moreStart >= length) { + var m = moreStart; + var l = lessStart; + while (m < moreEnd && l < lessEnd && compare(moreNodes[m], lessNodes[l])) { + m++; + l++; } - }); - Object.defineProperties(Component.prototype, { - // all events are handled with the component as context - handleEvent: { - value: function value(e) { - var ct = e.currentTarget; - this['getAttribute' in ct && ct.getAttribute('data-call') || 'on' + e.type](e); - } - }, - // components will lazily define html or svg properties - // as soon as these are invoked within the .render() method - // Such render() method is not provided by the base class - // but it must be available through the Component extend. - // Declared components could implement a - // render(props) method too and use props as needed. - html: lazyGetter('html', content), - svg: lazyGetter('svg', content), - // the state is a very basic/simple mechanism inspired by Preact - state: lazyGetter('state', function () { - return this.defaultState; - }), - // it is possible to define a default state that'd be always an object otherwise - defaultState: { - get: function get() { - return {}; - } - }, - // dispatch a bubbling, cancelable, custom event - // through the first known/available node - dispatch: { - value: function value(type, detail) { - var _wire$ = this._wire$; + if (l === lessEnd) return moreStart; + moreStart = m + 1; + } + return -1; + }; - if (_wire$) { - var event = new CustomEvent(type, { - bubbles: true, - cancelable: true, - detail: detail - }); - event.component = this; - return (_wire$.dispatchEvent ? _wire$ : _wire$.childNodes[0]).dispatchEvent(event); - } - return false; - } - }, - // setting some property state through a new object - // or a callback, triggers also automatically a render - // unless explicitly specified to not do so (render === false) - setState: { - value: function value(state, render) { - var target = this.state; - var source = typeof state === 'function' ? state.call(this, target) : state; - for (var key in source) { - target[key] = source[key]; - }if (render !== false) this.render(); - return this; - } - } - }); - } + var isReversed = function isReversed(futureNodes, futureEnd, currentNodes, currentStart, currentEnd, compare) { + while (currentStart < currentEnd && compare(currentNodes[currentStart], futureNodes[futureEnd - 1])) { + currentStart++; + futureEnd--; + } return futureEnd === 0; + }; - // instead of a secret key I could've used a WeakMap - // However, attaching a property directly will result - // into better performance with thousands of components - // hanging around, and less memory pressure caused by the WeakMap - var lazyGetter = function lazyGetter(type, fn) { - var secret = '_' + type + '$'; - return { - get: function get() { - return this[secret] || setValue(this, secret, fn.call(this, type)); - }, - set: function set(value) { - setValue(this, secret, value); - } - }; + var next = function next(get, list, i, length, before) { + return i < length ? get(list[i], 0) : 0 < i ? get(list[i - 1], -0).nextSibling : before; }; - // shortcut to set value on get or set(value) - var setValue = function setValue(self, secret, value) { - return Object.defineProperty(self, secret, { - configurable: true, - value: typeof value === 'function' ? function () { - return self._wire$ = value.apply(this, arguments); - } : value - })[secret]; + var remove = function remove(get, parent, children, start, end) { + if (end - start < 2) parent.removeChild(get(children[start], -1));else { + var range = parent.ownerDocument.createRange(); + range.setStartBefore(get(children[start], -1)); + range.setEndAfter(get(children[end - 1], -1)); + range.deleteContents(); + } }; - var attributes = {}; - var intents = {}; - var keys = []; - var hasOwnProperty = intents.hasOwnProperty; + // - - - - - - - - - - - - - - - - - - - + // diff related constants and utilities + // - - - - - - - - - - - - - - - - - - - - var length = 0; + var DELETION = -1; + var INSERTION = 1; + var SKIP = 0; + var SKIP_OND = 50; - var Intent = { + var HS = function HS(futureNodes, futureStart, futureEnd, futureChanges, currentNodes, currentStart, currentEnd, currentChanges) { - // used to invoke right away hyper:attributes - attributes: attributes, + var k = 0; + /* istanbul ignore next */ + var minLen = futureChanges < currentChanges ? futureChanges : currentChanges; + var link = Array(minLen++); + var tresh = Array(minLen); + tresh[0] = -1; - // hyperHTML.define('intent', (object, update) => {...}) - // can be used to define a third parts update mechanism - // when every other known mechanism failed. - // hyper.define('user', info => info.name); - // hyper(node)`

${{user}}

`; - define: function define(intent, callback) { - if (intent.indexOf('-') < 0) { - if (!(intent in intents)) { - length = keys.push(intent); + for (var i = 1; i < minLen; i++) { + tresh[i] = currentEnd; + }var keymap = new Map$1(); + for (var _i = currentStart; _i < currentEnd; _i++) { + keymap.set(currentNodes[_i], _i); + }for (var _i2 = futureStart; _i2 < futureEnd; _i2++) { + var idxInOld = keymap.get(futureNodes[_i2]); + if (idxInOld != null) { + k = findK(tresh, minLen, idxInOld); + /* istanbul ignore else */ + if (-1 < k) { + tresh[k] = idxInOld; + link[k] = { + newi: _i2, + oldi: idxInOld, + prev: link[k - 1] + }; } - intents[intent] = callback; - } else { - attributes[intent] = callback; } - }, + } - // this method is used internally as last resort - // to retrieve a value out of an object - invoke: function invoke(object, callback) { - for (var i = 0; i < length; i++) { - var key = keys[i]; - if (hasOwnProperty.call(object, key)) { - return intents[key](object[key], callback); - } + k = --minLen; + --currentEnd; + while (tresh[k] > currentEnd) { + --k; + }minLen = currentChanges + futureChanges - k; + var diff = Array(minLen); + var ptr = link[k]; + --futureEnd; + while (ptr) { + var _ptr = ptr, + newi = _ptr.newi, + oldi = _ptr.oldi; + + while (futureEnd > newi) { + diff[--minLen] = INSERTION; + --futureEnd; + } + while (currentEnd > oldi) { + diff[--minLen] = DELETION; + --currentEnd; } + diff[--minLen] = SKIP; + --futureEnd; + --currentEnd; + ptr = ptr.prev; + } + while (futureEnd >= futureStart) { + diff[--minLen] = INSERTION; + --futureEnd; + } + while (currentEnd >= currentStart) { + diff[--minLen] = DELETION; + --currentEnd; } + return diff; }; - // TODO: I'd love to code-cover RegExp too here - // these are fundamental for this library - - var spaces = ' \\f\\n\\r\\t'; - var almostEverything = '[^ ' + spaces + '\\/>"\'=]+'; - var attrName = '[ ' + spaces + ']+' + almostEverything; - var tagName = '<([A-Za-z]+[A-Za-z0-9:_-]*)((?:'; - var attrPartials = '(?:=(?:\'[^\']*?\'|"[^"]*?"|<[^>]*?>|' + almostEverything + '))?)'; - - var attrSeeker = new RegExp(tagName + attrName + attrPartials + '+)([ ' + spaces + ']*/?>)', 'g'); - - var selfClosing = new RegExp(tagName + attrName + attrPartials + '*)([ ' + spaces + ']*/>)', 'g'); + // this is pretty much the same petit-dom code without the delete map part + // https://github.com/yelouafi/petit-dom/blob/bd6f5c919b5ae5297be01612c524c40be45f14a7/src/vdom.js#L556-L561 + var OND = function OND(futureNodes, futureStart, rows, currentNodes, currentStart, cols, compare) { + var length = rows + cols; + var v = []; + var d = void 0, + k = void 0, + r = void 0, + c = void 0, + pv = void 0, + cv = void 0, + pd = void 0; + outer: for (d = 0; d <= length; d++) { + /* istanbul ignore if */ + if (d > SKIP_OND) return null; + pd = d - 1; + /* istanbul ignore next */ + pv = d ? v[d - 1] : [0, 0]; + cv = v[d] = []; + for (k = -d; k <= d; k += 2) { + if (k === -d || k !== d && pv[pd + k - 1] < pv[pd + k + 1]) { + c = pv[pd + k + 1]; + } else { + c = pv[pd + k - 1] + 1; + } + r = c - k; + while (c < cols && r < rows && compare(currentNodes[currentStart + c], futureNodes[futureStart + r])) { + c++; + r++; + } + if (c === cols && r === rows) { + break outer; + } + cv[d + k] = c; + } + } - // these are tiny helpers to simplify most common operations needed here - var create = function create(node, type) { - return doc(node).createElement(type); + var diff = Array(d / 2 + length / 2); + var diffIdx = diff.length - 1; + for (d = v.length - 1; d >= 0; d--) { + while (c > 0 && r > 0 && compare(currentNodes[currentStart + c - 1], futureNodes[futureStart + r - 1])) { + // diagonal edge = equality + diff[diffIdx--] = SKIP; + c--; + r--; + } + if (!d) break; + pd = d - 1; + /* istanbul ignore next */ + pv = d ? v[d - 1] : [0, 0]; + k = c - r; + if (k === -d || k !== d && pv[pd + k - 1] < pv[pd + k + 1]) { + // vertical edge = insertion + r--; + diff[diffIdx--] = INSERTION; + } else { + // horizontal edge = deletion + c--; + diff[diffIdx--] = DELETION; + } + } + return diff; }; - var doc = function doc(node) { - return node.ownerDocument || node; + + var applyDiff = function applyDiff(diff, get, parentNode, futureNodes, futureStart, currentNodes, currentStart, currentLength, before) { + var live = new Map$1(); + var length = diff.length; + var currentIndex = currentStart; + var i = 0; + while (i < length) { + switch (diff[i++]) { + case SKIP: + futureStart++; + currentIndex++; + break; + case INSERTION: + // TODO: bulk appends for sequential nodes + live.set(futureNodes[futureStart], 1); + append(get, parentNode, futureNodes, futureStart++, futureStart, currentIndex < currentLength ? get(currentNodes[currentIndex], 1) : before); + break; + case DELETION: + currentIndex++; + break; + } + } + i = 0; + while (i < length) { + switch (diff[i++]) { + case SKIP: + currentStart++; + break; + case DELETION: + // TODO: bulk removes for sequential nodes + if (live.has(currentNodes[currentStart])) currentStart++;else remove(get, parentNode, currentNodes, currentStart++, currentStart); + break; + } + } }; - var fragment = function fragment(node) { - return doc(node).createDocumentFragment(); + + var findK = function findK(ktr, length, j) { + var lo = 1; + var hi = length; + while (lo < hi) { + var mid = (lo + hi) / 2 >>> 0; + if (j < ktr[mid]) hi = mid;else lo = mid + 1; + } + return lo; }; - var text = function text(node, _text) { - return doc(node).createTextNode(_text); + + var smartDiff = function smartDiff(get, parentNode, futureNodes, futureStart, futureEnd, futureChanges, currentNodes, currentStart, currentEnd, currentChanges, currentLength, compare, before) { + applyDiff(OND(futureNodes, futureStart, futureChanges, currentNodes, currentStart, currentChanges, compare) || HS(futureNodes, futureStart, futureEnd, futureChanges, currentNodes, currentStart, currentEnd, currentChanges), get, parentNode, futureNodes, futureStart, currentNodes, currentStart, currentLength, before); }; - var testFragment = fragment(document); + /*! (c) 2018 Andrea Giammarchi (ISC) */ - // DOM4 node.append(...many) - var hasAppend = 'append' in testFragment; + var domdiff = function domdiff(parentNode, // where changes happen + currentNodes, // Array of current items/nodes + futureNodes, // Array of future items/nodes + options // optional object with one of the following properties + // before: domNode + // compare(generic, generic) => true if same generic + // node(generic) => Node + ) { + if (!options) options = {}; - // detect old browsers without HTMLTemplateElement content support - var hasContent = 'content' in create(document, 'template'); + var compare = options.compare || eqeq; + var get = options.node || identity; + var before = options.before == null ? null : get(options.before, 0); - // IE 11 has problems with cloning templates: it "forgets" empty childNodes - testFragment.appendChild(text(testFragment, 'g')); - testFragment.appendChild(text(testFragment, '')); - var hasDoomedCloneNode = testFragment.cloneNode(true).childNodes.length === 1; + var currentLength = currentNodes.length; + var currentEnd = currentLength; + var currentStart = 0; - // old browsers need to fallback to cloneNode - // Custom Elements V0 and V1 will work polyfilled - // but native implementations need importNode instead - // (specially Chromium and its old V0 implementation) - var hasImportNode = 'importNode' in document; + var futureEnd = futureNodes.length; + var futureStart = 0; - // appends an array of nodes - // to a generic node/fragment - // When available, uses append passing all arguments at once - // hoping that's somehow faster, even if append has more checks on type - var append = hasAppend ? function (node, childNodes) { - node.append.apply(node, childNodes); - } : function (node, childNodes) { - var length = childNodes.length; - for (var i = 0; i < length; i++) { - node.appendChild(childNodes[i]); + // common prefix + while (currentStart < currentEnd && futureStart < futureEnd && compare(currentNodes[currentStart], futureNodes[futureStart])) { + currentStart++; + futureStart++; } - }; - var findAttributes = new RegExp('(' + attrName + '=)([\'"]?)' + UIDC + '\\2', 'gi'); - var comments = function comments($0, $1, $2, $3) { - return '<' + $1 + $2.replace(findAttributes, replaceAttributes) + $3; - }; - var replaceAttributes = function replaceAttributes($0, $1, $2) { - return $1 + ($2 || '"') + UID + ($2 || '"'); - }; - - // given a node and a generic HTML content, - // create either an SVG or an HTML fragment - // where such content will be injected - var createFragment = function createFragment(node, html) { - return (OWNER_SVG_ELEMENT in node ? SVGFragment : HTMLFragment)(node, html.replace(attrSeeker, comments)); - }; - - // IE/Edge shenanigans proof cloneNode - // it goes through all nodes manually - // instead of relying the engine to suddenly - // merge nodes together - var cloneNode = hasDoomedCloneNode ? function (node) { - var clone = node.cloneNode(); - var childNodes = node.childNodes || - // this is an excess of caution - // but some node, in IE, might not - // have childNodes property. - // The following fallback ensure working code - // in older IE without compromising performance - // or any other browser/engine involved. - /* istanbul ignore next */ - []; - var length = childNodes.length; - for (var i = 0; i < length; i++) { - clone.appendChild(cloneNode(childNodes[i])); + // common suffix + while (currentStart < currentEnd && futureStart < futureEnd && compare(currentNodes[currentEnd - 1], futureNodes[futureEnd - 1])) { + currentEnd--; + futureEnd--; } - return clone; - } : - // the following ignore is due code-coverage - // combination of not having document.importNode - // but having a working node.cloneNode. - // This shenario is common on older Android/WebKit browsers - // but basicHTML here tests just two major cases: - // with document.importNode or with broken cloneNode. - /* istanbul ignore next */ - function (node) { - return node.cloneNode(true); - }; - - // used to import html into fragments - var importNode = hasImportNode ? function (doc$$1, node) { - return doc$$1.importNode(node, true); - } : function (doc$$1, node) { - return cloneNode(node); - }; - - // just recycling a one-off array to use slice - // in every needed place - var slice = [].slice; - // lazy evaluated, returns the unique identity - // of a template literal, as tempalte literal itself. - // By default, ES2015 template literals are unique - // tag`a${1}z` === tag`a${2}z` - // even if interpolated values are different - // the template chunks are in a frozen Array - // that is identical each time you use the same - // literal to represent same static content - // around its own interpolations. - var unique = function unique(template) { - return _TL(template); - }; + var currentSame = currentStart === currentEnd; + var futureSame = futureStart === futureEnd; - // https://codepen.io/WebReflection/pen/dqZrpV?editors=0010 - // TL returns a unique version of the template - // it needs lazy feature detection - // (cannot trust literals with transpiled code) - var _TL = function TL(t) { - if ( - // TypeScript template literals are not standard - t.propertyIsEnumerable('raw') || !Object.isFrozen(t.raw) || - // Firefox < 55 has not standard implementation neither - /Firefox\/(\d+)/.test((G.navigator || {}).userAgent) && parseFloat(RegExp.$1) < 55) { - var T = {}; - _TL = function TL(t) { - var k = '^' + t.join('^'); - return T[k] || (T[k] = t); - }; - } else { - // make TL an identity like function - _TL = function TL(t) { - return t; - }; - } - return _TL(t); - }; + // same list + if (currentSame && futureSame) return futureNodes; - // used to store templates objects - // since neither Map nor WeakMap are safe - var TemplateMap = function TemplateMap() { - try { - var wm = new WeakMap(); - var o_O = Object.freeze([]); - wm.set(o_O, true); - if (!wm.get(o_O)) throw o_O; - return wm; - } catch (o_O) { - // inevitable legacy code leaks due - // https://github.com/tc39/ecma262/pull/890 - return new Map$1(); + // only stuff to add + if (currentSame && futureStart < futureEnd) { + append(get, parentNode, futureNodes, futureStart, futureEnd, next(get, currentNodes, currentStart, currentLength, before)); + return futureNodes; } - }; - // create document fragments via native template - // with a fallback for browsers that won't be able - // to deal with some injected element such or others - var HTMLFragment = hasContent ? function (node, html) { - var container = create(node, 'template'); - container.innerHTML = html; - return container.content; - } : function (node, html) { - var container = create(node, 'template'); - var content = fragment(node); - if (/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(html)) { - var selector = RegExp.$1; - container.innerHTML = '' + html + '
'; - append(content, slice.call(container.querySelectorAll(selector))); - } else { - container.innerHTML = html; - append(content, slice.call(container.childNodes)); + // only stuff to remove + if (futureSame && currentStart < currentEnd) { + remove(get, parentNode, currentNodes, currentStart, currentEnd); + return futureNodes; } - return content; - }; - - // creates SVG fragment with a fallback for IE that needs SVG - // within the HTML content - var SVGFragment = hasContent ? function (node, html) { - var content = fragment(node); - var container = doc(node).createElementNS(SVG_NAMESPACE, 'svg'); - container.innerHTML = html; - append(content, slice.call(container.childNodes)); - return content; - } : function (node, html) { - var content = fragment(node); - var container = create(node, 'div'); - container.innerHTML = '' + html + ''; - append(content, slice.call(container.firstChild.childNodes)); - return content; - }; - function Wire(childNodes) { - this.childNodes = childNodes; - this.length = childNodes.length; - this.first = childNodes[0]; - this.last = childNodes[this.length - 1]; - this._ = null; - } + var currentChanges = currentEnd - currentStart; + var futureChanges = futureEnd - futureStart; + var i = -1; - // when a wire is inserted, all its nodes will follow - Wire.prototype.valueOf = function valueOf(different) { - var noFragment = this._ == null; - if (noFragment) this._ = fragment(this.first); + // 2 simple indels: the shortest sequence is a subsequence of the longest + if (currentChanges < futureChanges) { + i = indexOf(futureNodes, futureStart, futureEnd, currentNodes, currentStart, currentEnd, compare); + // inner diff + if (-1 < i) { + append(get, parentNode, futureNodes, futureStart, i, get(currentNodes[currentStart], 0)); + append(get, parentNode, futureNodes, i + currentChanges, futureEnd, next(get, currentNodes, currentEnd, currentLength, before)); + return futureNodes; + } + } /* istanbul ignore else */ - if (noFragment || different) append(this._, this.childNodes); - return this._; - }; + else if (futureChanges < currentChanges) { + i = indexOf(currentNodes, currentStart, currentEnd, futureNodes, futureStart, futureEnd, compare); + // outer diff + if (-1 < i) { + remove(get, parentNode, currentNodes, currentStart, i); + remove(get, parentNode, currentNodes, i + futureChanges, currentEnd); + return futureNodes; + } + } - // when a wire is removed, all its nodes must be removed as well - Wire.prototype.remove = function remove() { - this._ = null; - var first = this.first; - var last = this.last; - if (this.length === 2) { - last.parentNode.removeChild(last); - } else { - var range = doc(first).createRange(); - range.setStartBefore(this.childNodes[1]); - range.setEndAfter(last); - range.deleteContents(); + // common case with one replacement for many nodes + // or many nodes replaced for a single one + /* istanbul ignore else */ + if (currentChanges < 2 || futureChanges < 2) { + append(get, parentNode, futureNodes, futureStart, futureEnd, get(currentNodes[currentStart], 0)); + remove(get, parentNode, currentNodes, currentStart, currentEnd); + return futureNodes; } - return first; - }; - // every template literal interpolation indicates - // a precise target in the DOM the template is representing. - // `

some ${'content'}

` - // hyperHTML finds only once per template literal, - // hence once per entire application life-cycle, - // all nodes that are related to interpolations. - // These nodes are stored as indexes used to retrieve, - // once per upgrade, nodes that will change on each future update. - // A path example is [2, 0, 1] representing the operation: - // node.childNodes[2].childNodes[0].childNodes[1] - // Attributes are addressed via their owner node and their name. - var createPath = function createPath(node) { - var path = []; - var parentNode = void 0; - switch (node.nodeType) { - case ELEMENT_NODE: - case DOCUMENT_FRAGMENT_NODE: - parentNode = node; - break; - case COMMENT_NODE: - parentNode = node.parentNode; - prepend(path, parentNode, node); - break; - default: - parentNode = node.ownerElement; - break; - } - for (node = parentNode; parentNode = parentNode.parentNode; node = parentNode) { - prepend(path, parentNode, node); + // the half match diff part has been skipped in petit-dom + // https://github.com/yelouafi/petit-dom/blob/bd6f5c919b5ae5297be01612c524c40be45f14a7/src/vdom.js#L391-L397 + // accordingly, I think it's safe to skip in here too + // if one day it'll come out like the speediest thing ever to do + // then I might add it in here too + + // Extra: before going too fancy, what about reversed lists ? + // This should bail out pretty quickly if that's not the case. + if (currentChanges === futureChanges && isReversed(futureNodes, futureEnd, currentNodes, currentStart, currentEnd, compare)) { + append(get, parentNode, futureNodes, futureStart, futureEnd, next(get, currentNodes, currentEnd, currentLength, before)); + return futureNodes; } - return path; - }; - var prepend = function prepend(path, parent, node) { - path.unshift(path.indexOf.call(parent.childNodes, node)); - }; + // last resort through a smart diff + smartDiff(get, parentNode, futureNodes, futureStart, futureEnd, futureChanges, currentNodes, currentStart, currentEnd, currentChanges, currentLength, compare, before); - var Path = { - create: function create(type, node, name) { - return { type: type, name: name, node: node, path: createPath(node) }; - }, - find: function find(node, path) { - var length = path.length; - for (var i = 0; i < length; i++) { - node = node.childNodes[path[i]]; - } - return node; - } + return futureNodes; }; - // from https://github.com/developit/preact/blob/33fc697ac11762a1cb6e71e9847670d047af7ce5/src/constants.js - var IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i; + /*! (c) Andrea Giammarchi - ISC */ + var self$3 = null || /* istanbul ignore next */{}; + try { + self$3.CustomEvent = new CustomEvent('.').constructor; + } catch (CustomEvent) { + self$3.CustomEvent = function CustomEvent(type, init) { + if (!init) init = {}; + var e = document.createEvent('Event'); + var bubbles = !!init.bubbles; + var cancelable = !!init.cancelable; + e.initEvent(type, bubbles, cancelable); + e.bubbles = bubbles; + e.cancelable = cancelable; + e.detail = init.detail; + return e; + }; + } + var CustomEvent$1 = self$3.CustomEvent; - // style is handled as both string and object - // even if the target is an SVG element (consistency) - var Style = (function (node, original, isSVG) { - if (isSVG) { - var style = original.cloneNode(true); - style.value = ''; - node.setAttributeNode(style); - return update(style, isSVG); - } - return update(node.style, isSVG); - }); + // hyperHTML.Component is a very basic class + // able to create Custom Elements like components + // including the ability to listen to connect/disconnect + // events via onconnect/ondisconnect attributes + // Components can be created imperatively or declaratively. + // The main difference is that declared components + // will not automatically render on setState(...) + // to simplify state handling on render. + function Component() { + return this; // this is needed in Edge !!! + } - // the update takes care or changing/replacing - // only properties that are different or - // in case of string, the whole node - var update = function update(style, isSVG) { - var oldType = void 0, - oldValue = void 0; - return function (newValue) { - switch (typeof newValue) { + // Component is lazily setup because it needs + // wire mechanism as lazy content + function setup(content) { + // there are various weakly referenced variables in here + // and mostly are to use Component.for(...) static method. + var children = new WeakMap$1(); + var create = Object.create; + var createEntry = function createEntry(wm, id, component) { + wm.set(id, component); + return component; + }; + var get = function get(Class, info, context, id) { + var relation = info.get(Class) || relate(Class, info); + switch (typeof id) { case 'object': - if (newValue) { - if (oldType === 'object') { - if (!isSVG) { - if (oldValue !== newValue) { - for (var key in oldValue) { - if (!(key in newValue)) { - style[key] = ''; - } - } - } - } - } else { - if (isSVG) style.value = '';else style.cssText = ''; - } - var info = isSVG ? {} : style; - for (var _key in newValue) { - var value = newValue[_key]; - var styleValue = typeof value === 'number' && !IS_NON_DIMENSIONAL.test(_key) ? value + 'px' : value; - if (!isSVG && /^--/.test(_key)) info.setProperty(_key, styleValue);else info[_key] = styleValue; - } - oldType = 'object'; - if (isSVG) style.value = toStyle(oldValue = info);else oldValue = newValue; - break; - } + case 'function': + var wm = relation.w || (relation.w = new WeakMap$1()); + return wm.get(id) || createEntry(wm, id, new Class(context)); default: - if (oldValue != newValue) { - oldType = 'string'; - oldValue = newValue; - if (isSVG) style.value = newValue || '';else style.cssText = newValue || ''; + var sm = relation.p || (relation.p = create(null)); + return sm[id] || (sm[id] = new Class(context)); + } + }; + var relate = function relate(Class, info) { + var relation = { w: null, p: null }; + info.set(Class, relation); + return relation; + }; + var set = function set(context) { + var info = new Map$1(); + children.set(context, info); + return info; + }; + // The Component Class + Object.defineProperties(Component, { + // Component.for(context[, id]) is a convenient way + // to automatically relate data/context to children components + // If not created yet, the new Component(context) is weakly stored + // and after that same instance would always be returned. + for: { + configurable: true, + value: function value(context, id) { + return get(this, children.get(context) || set(context), context, id == null ? 'default' : id); + } + } + }); + Object.defineProperties(Component.prototype, { + // all events are handled with the component as context + handleEvent: { + value: function value(e) { + var ct = e.currentTarget; + this['getAttribute' in ct && ct.getAttribute('data-call') || 'on' + e.type](e); + } + }, + // components will lazily define html or svg properties + // as soon as these are invoked within the .render() method + // Such render() method is not provided by the base class + // but it must be available through the Component extend. + // Declared components could implement a + // render(props) method too and use props as needed. + html: lazyGetter('html', content), + svg: lazyGetter('svg', content), + // the state is a very basic/simple mechanism inspired by Preact + state: lazyGetter('state', function () { + return this.defaultState; + }), + // it is possible to define a default state that'd be always an object otherwise + defaultState: { + get: function get() { + return {}; + } + }, + // dispatch a bubbling, cancelable, custom event + // through the first known/available node + dispatch: { + value: function value(type, detail) { + var _wire$ = this._wire$; + + if (_wire$) { + var event = new CustomEvent$1(type, { + bubbles: true, + cancelable: true, + detail: detail + }); + event.component = this; + return (_wire$.dispatchEvent ? _wire$ : _wire$.childNodes[0]).dispatchEvent(event); } - break; + return false; + } + }, + // setting some property state through a new object + // or a callback, triggers also automatically a render + // unless explicitly specified to not do so (render === false) + setState: { + value: function value(state, render) { + var target = this.state; + var source = typeof state === 'function' ? state.call(this, target) : state; + for (var key in source) { + target[key] = source[key]; + }if (render !== false) this.render(); + return this; + } + } + }); + } + + // instead of a secret key I could've used a WeakMap + // However, attaching a property directly will result + // into better performance with thousands of components + // hanging around, and less memory pressure caused by the WeakMap + var lazyGetter = function lazyGetter(type, fn) { + var secret = '_' + type + '$'; + return { + get: function get() { + return this[secret] || setValue(this, secret, fn.call(this, type)); + }, + set: function set(value) { + setValue(this, secret, value); } }; }; - var hyphen = /([^A-Z])([A-Z]+)/g; - var ized = function ized($0, $1, $2) { - return $1 + '-' + $2.toLowerCase(); - }; - var toStyle = function toStyle(object) { - var css = []; - for (var key in object) { - css.push(key.replace(hyphen, ized), ':', object[key], ';'); - } - return css.join(''); + // shortcut to set value on get or set(value) + var setValue = function setValue(self, secret, value) { + return Object.defineProperty(self, secret, { + configurable: true, + value: typeof value === 'function' ? function () { + return self._wire$ = value.apply(this, arguments); + } : value + })[secret]; }; - /* AUTOMATICALLY IMPORTED, DO NOT MODIFY */ - var append$1 = function append(get, parent, children, start, end, before) { - if (end - start < 2) parent.insertBefore(get(children[start], 1), before);else { - var fragment = parent.ownerDocument.createDocumentFragment(); - while (start < end) { - fragment.appendChild(get(children[start++], 1)); - }parent.insertBefore(fragment, before); - } - }; + var attributes = {}; + var intents = {}; + var keys = []; + var hasOwnProperty = intents.hasOwnProperty; - var eqeq = function eqeq(a, b) { - return a == b; - }; + var length = 0; - var identity = function identity(O) { - return O; - }; + var Intent = { - var indexOf = function indexOf(moreNodes, moreStart, moreEnd, lessNodes, lessStart, lessEnd, compare) { - var length = lessEnd - lessStart; - /* istanbul ignore if */ - if (length < 1) return -1; - while (moreEnd - moreStart >= length) { - var m = moreStart; - var l = lessStart; - while (m < moreEnd && l < lessEnd && compare(moreNodes[m], lessNodes[l])) { - m++; - l++; + // used to invoke right away hyper:attributes + attributes: attributes, + + // hyperHTML.define('intent', (object, update) => {...}) + // can be used to define a third parts update mechanism + // when every other known mechanism failed. + // hyper.define('user', info => info.name); + // hyper(node)`

${{user}}

`; + define: function define(intent, callback) { + if (intent.indexOf('-') < 0) { + if (!(intent in intents)) { + length = keys.push(intent); + } + intents[intent] = callback; + } else { + attributes[intent] = callback; + } + }, + + // this method is used internally as last resort + // to retrieve a value out of an object + invoke: function invoke(object, callback) { + for (var i = 0; i < length; i++) { + var key = keys[i]; + if (hasOwnProperty.call(object, key)) { + return intents[key](object[key], callback); + } } - if (l === lessEnd) return moreStart; - moreStart = m + 1; } - return -1; }; - var isReversed = function isReversed(futureNodes, futureEnd, currentNodes, currentStart, currentEnd, compare) { - while (currentStart < currentEnd && compare(currentNodes[currentStart], futureNodes[futureEnd - 1])) { - currentStart++; - futureEnd--; - } return futureEnd === 0; - }; + var isArray = Array.isArray || function (toString) { + var $ = toString.call([]); + return function isArray(object) { + return toString.call(object) === $; + }; + }({}.toString); - var next = function next(get, list, i, length, before) { - return i < length ? get(list[i], 0) : 0 < i ? get(list[i - 1], -0).nextSibling : before; + var trim = ''.trim || function () { + return String(this).replace(/^\s+|\s+/g, ''); }; - var remove = function remove(get, parent, children, start, end) { - if (end - start < 2) parent.removeChild(get(children[start], -1));else { - var range = parent.ownerDocument.createRange(); - range.setStartBefore(get(children[start], -1)); - range.setEndAfter(get(children[end - 1], -1)); - range.deleteContents(); + /*! (c) Andrea Giammarchi */ + function disconnected(poly) { + + var CONNECTED = 'connected'; + var DISCONNECTED = 'dis' + CONNECTED; + var Event = poly.Event; + var WeakSet = poly.WeakSet; + var notObserving = true; + var observer = new WeakSet(); + return function observe(node) { + if (notObserving) { + notObserving = !notObserving; + startObserving(node.ownerDocument); + } + observer.add(node); + return node; + }; + function startObserving(document) { + var dispatched = null; + try { + new MutationObserver(changes).observe(document, { subtree: true, childList: true }); + } catch (o_O) { + var timer = 0; + var records = []; + var reschedule = function reschedule(record) { + records.push(record); + clearTimeout(timer); + timer = setTimeout(function () { + changes(records.splice(timer = 0, records.length)); + }, 0); + }; + document.addEventListener('DOMNodeRemoved', function (event) { + reschedule({ addedNodes: [], removedNodes: [event.target] }); + }, true); + document.addEventListener('DOMNodeInserted', function (event) { + reschedule({ addedNodes: [event.target], removedNodes: [] }); + }, true); + } + function changes(records) { + dispatched = new Tracker(); + for (var record, length = records.length, i = 0; i < length; i++) { + record = records[i]; + dispatchAll(record.removedNodes, DISCONNECTED, CONNECTED); + dispatchAll(record.addedNodes, CONNECTED, DISCONNECTED); + } + dispatched = null; + } + function dispatchAll(nodes, type, counter) { + for (var node, event = new Event(type), length = nodes.length, i = 0; i < length; (node = nodes[i++]).nodeType === 1 && dispatchTarget(node, event, type, counter)) {} + } + function dispatchTarget(node, event, type, counter) { + if (observer.has(node) && !dispatched[type].has(node)) { + dispatched[counter].delete(node); + dispatched[type].add(node); + node.dispatchEvent(event); + /* + // The event is not bubbling (perf reason: should it?), + // hence there's no way to know if + // stop/Immediate/Propagation() was called. + // Should DOM Level 0 work at all? + // I say it's a YAGNI case for the time being, + // and easy to implement in user-land. + if (!event.cancelBubble) { + var fn = node['on' + type]; + if (fn) + fn.call(node, event); + } + */ + } + for (var children = node.children, length = children.length, i = 0; i < length; dispatchTarget(children[i++], event, type, counter)) {} + } + function Tracker() { + this[CONNECTED] = new WeakSet(); + this[DISCONNECTED] = new WeakSet(); + } } - }; + } - // - - - - - - - - - - - - - - - - - - - - // diff related constants and utilities - // - - - - - - - - - - - - - - - - - - - + var G = document.defaultView; - var DELETION = -1; - var INSERTION = 1; - var SKIP = 0; - var SKIP_OND = 50; + // Node.CONSTANTS + // 'cause some engine has no global Node defined + // (i.e. Node, NativeScript, basicHTML ... ) + var ELEMENT_NODE = 1; + var TEXT_NODE = 3; + var COMMENT_NODE = 8; + var DOCUMENT_FRAGMENT_NODE = 11; - /* istanbul ignore next */ - var Rel = typeof Map === 'undefined' ? function () { - var k = [], - v = []; - return { - has: function has(key) { - return -1 < k.indexOf(key); - }, - get: function get(key) { - return v[k.indexOf(key)]; - }, - set: function set(key, value) { - var i = k.indexOf(key); - v[i < 0 ? k.push(key) - 1 : i] = value; - } - }; - } : Map; + // HTML related constants + var VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i; - var HS = function HS(futureNodes, futureStart, futureEnd, futureChanges, currentNodes, currentStart, currentEnd, currentChanges) { + // SVG related constants + var OWNER_SVG_ELEMENT = 'ownerSVGElement'; + var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; - var k = 0; - /* istanbul ignore next */ - var minLen = futureChanges < currentChanges ? futureChanges : currentChanges; - var link = Array(minLen++); - var tresh = Array(minLen); - tresh[0] = -1; + // Custom Elements / MutationObserver constants + var CONNECTED = 'connected'; + var DISCONNECTED = 'dis' + CONNECTED; - for (var i = 1; i < minLen; i++) { - tresh[i] = currentEnd; - }var keymap = new Rel(); - for (var _i = currentStart; _i < currentEnd; _i++) { - keymap.set(currentNodes[_i], _i); - }for (var _i2 = futureStart; _i2 < futureEnd; _i2++) { - var idxInOld = keymap.get(futureNodes[_i2]); - if (idxInOld != null) { - k = findK(tresh, minLen, idxInOld); - /* istanbul ignore else */ - if (-1 < k) { - tresh[k] = idxInOld; - link[k] = { - newi: _i2, - oldi: idxInOld, - prev: link[k - 1] - }; - } - } - } + // hyperHTML related constants + var EXPANDO = '_hyper: '; + var SHOULD_USE_TEXT_CONTENT = /^(?:style|textarea)$/i; + var UID = EXPANDO + (Math.random() * new Date() | 0) + ';'; + var UIDC = ''; - k = --minLen; - --currentEnd; - while (tresh[k] > currentEnd) { - --k; - }minLen = currentChanges + futureChanges - k; - var diff = Array(minLen); - var ptr = link[k]; - --futureEnd; - while (ptr) { - var _ptr = ptr, - newi = _ptr.newi, - oldi = _ptr.oldi; + // TODO: I'd love to code-cover RegExp too here + // these are fundamental for this library - while (futureEnd > newi) { - diff[--minLen] = INSERTION; - --futureEnd; - } - while (currentEnd > oldi) { - diff[--minLen] = DELETION; - --currentEnd; - } - diff[--minLen] = SKIP; - --futureEnd; - --currentEnd; - ptr = ptr.prev; - } - while (futureEnd >= futureStart) { - diff[--minLen] = INSERTION; - --futureEnd; - } - while (currentEnd >= currentStart) { - diff[--minLen] = DELETION; - --currentEnd; - } - return diff; - }; + var spaces = ' \\f\\n\\r\\t'; + var almostEverything = '[^ ' + spaces + '\\/>"\'=]+'; + var attrName = '[ ' + spaces + ']+' + almostEverything; + var tagName = '<([A-Za-z]+[A-Za-z0-9:_-]*)((?:'; + var attrPartials = '(?:=(?:\'[^\']*?\'|"[^"]*?"|<[^>]*?>|' + almostEverything + '))?)'; - // this is pretty much the same petit-dom code without the delete map part - // https://github.com/yelouafi/petit-dom/blob/bd6f5c919b5ae5297be01612c524c40be45f14a7/src/vdom.js#L556-L561 - var OND = function OND(futureNodes, futureStart, rows, currentNodes, currentStart, cols, compare) { - var length = rows + cols; - var v = []; - var d = void 0, - k = void 0, - r = void 0, - c = void 0, - pv = void 0, - cv = void 0, - pd = void 0; - outer: for (d = 0; d <= length; d++) { - /* istanbul ignore if */ - if (d > SKIP_OND) return null; - pd = d - 1; - /* istanbul ignore next */ - pv = d ? v[d - 1] : [0, 0]; - cv = v[d] = []; - for (k = -d; k <= d; k += 2) { - if (k === -d || k !== d && pv[pd + k - 1] < pv[pd + k + 1]) { - c = pv[pd + k + 1]; - } else { - c = pv[pd + k - 1] + 1; - } - r = c - k; - while (c < cols && r < rows && compare(currentNodes[currentStart + c], futureNodes[futureStart + r])) { - c++; - r++; - } - if (c === cols && r === rows) { - break outer; - } - cv[d + k] = c; - } - } + var attrSeeker = new RegExp(tagName + attrName + attrPartials + '+)([ ' + spaces + ']*/?>)', 'g'); - var diff = Array(d / 2 + length / 2); - var diffIdx = diff.length - 1; - for (d = v.length - 1; d >= 0; d--) { - while (c > 0 && r > 0 && compare(currentNodes[currentStart + c - 1], futureNodes[futureStart + r - 1])) { - // diagonal edge = equality - diff[diffIdx--] = SKIP; - c--; - r--; - } - if (!d) break; - pd = d - 1; - /* istanbul ignore next */ - pv = d ? v[d - 1] : [0, 0]; - k = c - r; - if (k === -d || k !== d && pv[pd + k - 1] < pv[pd + k + 1]) { - // vertical edge = insertion - r--; - diff[diffIdx--] = INSERTION; - } else { - // horizontal edge = deletion - c--; - diff[diffIdx--] = DELETION; - } - } - return diff; + var selfClosing = new RegExp(tagName + attrName + attrPartials + '*)([ ' + spaces + ']*/>)', 'g'); + + // these are tiny helpers to simplify most common operations needed here + var create = function create(node, type) { + return doc(node).createElement(type); + }; + var doc = function doc(node) { + return node.ownerDocument || node; + }; + var fragment = function fragment(node) { + return doc(node).createDocumentFragment(); + }; + var text = function text(node, _text) { + return doc(node).createTextNode(_text); }; - var applyDiff = function applyDiff(diff, get, parentNode, futureNodes, futureStart, currentNodes, currentStart, currentLength, before) { - var live = new Rel(); - var length = diff.length; - var currentIndex = currentStart; - var i = 0; - while (i < length) { - switch (diff[i++]) { - case SKIP: - futureStart++; - currentIndex++; - break; - case INSERTION: - // TODO: bulk appends for sequential nodes - live.set(futureNodes[futureStart], 1); - append$1(get, parentNode, futureNodes, futureStart++, futureStart, currentIndex < currentLength ? get(currentNodes[currentIndex], 1) : before); - break; - case DELETION: - currentIndex++; - break; - } - } - i = 0; - while (i < length) { - switch (diff[i++]) { - case SKIP: - currentStart++; - break; - case DELETION: - // TODO: bulk removes for sequential nodes - if (live.has(currentNodes[currentStart])) currentStart++;else remove(get, parentNode, currentNodes, currentStart++, currentStart); - break; - } + var testFragment = fragment(document); + + // DOM4 node.append(...many) + var hasAppend = 'append' in testFragment; + + // detect old browsers without HTMLTemplateElement content support + var hasContent = 'content' in create(document, 'template'); + + // IE 11 has problems with cloning templates: it "forgets" empty childNodes + testFragment.appendChild(text(testFragment, 'g')); + testFragment.appendChild(text(testFragment, '')); + var hasDoomedCloneNode = testFragment.cloneNode(true).childNodes.length === 1; + + // old browsers need to fallback to cloneNode + // Custom Elements V0 and V1 will work polyfilled + // but native implementations need importNode instead + // (specially Chromium and its old V0 implementation) + var hasImportNode = 'importNode' in document; + + // appends an array of nodes + // to a generic node/fragment + // When available, uses append passing all arguments at once + // hoping that's somehow faster, even if append has more checks on type + var append$1 = hasAppend ? function (node, childNodes) { + node.append.apply(node, childNodes); + } : function (node, childNodes) { + var length = childNodes.length; + for (var i = 0; i < length; i++) { + node.appendChild(childNodes[i]); } }; - var findK = function findK(ktr, length, j) { - var lo = 1; - var hi = length; - while (lo < hi) { - var mid = (lo + hi) / 2 >>> 0; - if (j < ktr[mid]) hi = mid;else lo = mid + 1; - } - return lo; + var findAttributes = new RegExp('(' + attrName + '=)([\'"]?)' + UIDC + '\\2', 'gi'); + var comments = function comments($0, $1, $2, $3) { + return '<' + $1 + $2.replace(findAttributes, replaceAttributes) + $3; + }; + var replaceAttributes = function replaceAttributes($0, $1, $2) { + return $1 + ($2 || '"') + UID + ($2 || '"'); }; - var smartDiff = function smartDiff(get, parentNode, futureNodes, futureStart, futureEnd, futureChanges, currentNodes, currentStart, currentEnd, currentChanges, currentLength, compare, before) { - applyDiff(OND(futureNodes, futureStart, futureChanges, currentNodes, currentStart, currentChanges, compare) || HS(futureNodes, futureStart, futureEnd, futureChanges, currentNodes, currentStart, currentEnd, currentChanges), get, parentNode, futureNodes, futureStart, currentNodes, currentStart, currentLength, before); + // given a node and a generic HTML content, + // create either an SVG or an HTML fragment + // where such content will be injected + var createFragment = function createFragment(node, html) { + return (OWNER_SVG_ELEMENT in node ? SVGFragment : HTMLFragment)(node, html.replace(attrSeeker, comments)); }; - /* AUTOMATICALLY IMPORTED, DO NOT MODIFY */ + // IE/Edge shenanigans proof cloneNode + // it goes through all nodes manually + // instead of relying the engine to suddenly + // merge nodes together + var cloneNode = hasDoomedCloneNode ? function (node) { + var clone = node.cloneNode(); + var childNodes = node.childNodes || + // this is an excess of caution + // but some node, in IE, might not + // have childNodes property. + // The following fallback ensure working code + // in older IE without compromising performance + // or any other browser/engine involved. + /* istanbul ignore next */ + []; + var length = childNodes.length; + for (var i = 0; i < length; i++) { + clone.appendChild(cloneNode(childNodes[i])); + } + return clone; + } : + // the following ignore is due code-coverage + // combination of not having document.importNode + // but having a working node.cloneNode. + // This shenario is common on older Android/WebKit browsers + // but basicHTML here tests just two major cases: + // with document.importNode or with broken cloneNode. + /* istanbul ignore next */ + function (node) { + return node.cloneNode(true); + }; - var domdiff = function domdiff(parentNode, // where changes happen - currentNodes, // Array of current items/nodes - futureNodes, // Array of future items/nodes - options // optional object with one of the following properties - // before: domNode - // compare(generic, generic) => true if same generic - // node(generic) => Node - ) { - if (!options) options = {}; + // used to import html into fragments + var importNode = hasImportNode ? function (doc$$1, node) { + return doc$$1.importNode(node, true); + } : function (doc$$1, node) { + return cloneNode(node); + }; - var compare = options.compare || eqeq; - var get = options.node || identity; - var before = options.before == null ? null : get(options.before, 0); + // just recycling a one-off array to use slice + // in every needed place + var slice = [].slice; - var currentLength = currentNodes.length; - var currentEnd = currentLength; - var currentStart = 0; + // lazy evaluated, returns the unique identity + // of a template literal, as tempalte literal itself. + // By default, ES2015 template literals are unique + // tag`a${1}z` === tag`a${2}z` + // even if interpolated values are different + // the template chunks are in a frozen Array + // that is identical each time you use the same + // literal to represent same static content + // around its own interpolations. + var unique = function unique(template) { + return _TL(template); + }; - var futureEnd = futureNodes.length; - var futureStart = 0; + // https://codepen.io/WebReflection/pen/dqZrpV?editors=0010 + // TL returns a unique version of the template + // it needs lazy feature detection + // (cannot trust literals with transpiled code) + var _TL = function TL(t) { + if ( + // TypeScript template literals are not standard + t.propertyIsEnumerable('raw') || !Object.isFrozen(t.raw) || + // Firefox < 55 has not standard implementation neither + /Firefox\/(\d+)/.test((G.navigator || {}).userAgent) && parseFloat(RegExp.$1) < 55) { + var T = {}; + _TL = function TL(t) { + var k = '^' + t.join('^'); + return T[k] || (T[k] = t); + }; + } else { + // make TL an identity like function + _TL = function TL(t) { + return t; + }; + } + return _TL(t); + }; - // common prefix - while (currentStart < currentEnd && futureStart < futureEnd && compare(currentNodes[currentStart], futureNodes[futureStart])) { - currentStart++; - futureStart++; + // used to store templates objects + // since neither Map nor WeakMap are safe + var TemplateMap = function TemplateMap() { + try { + var wm = new WeakMap$1(); + var o_O = Object.freeze([]); + wm.set(o_O, true); + if (!wm.get(o_O)) throw o_O; + return wm; + } catch (o_O) { + // inevitable legacy code leaks due + // https://github.com/tc39/ecma262/pull/890 + return new Map$1(); } + }; - // common suffix - while (currentStart < currentEnd && futureStart < futureEnd && compare(currentNodes[currentEnd - 1], futureNodes[futureEnd - 1])) { - currentEnd--; - futureEnd--; + // create document fragments via native template + // with a fallback for browsers that won't be able + // to deal with some injected element such or others + var HTMLFragment = hasContent ? function (node, html) { + var container = create(node, 'template'); + container.innerHTML = html; + return container.content; + } : function (node, html) { + var container = create(node, 'template'); + var content = fragment(node); + if (/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(html)) { + var selector = RegExp.$1; + container.innerHTML = '' + html + '
'; + append$1(content, slice.call(container.querySelectorAll(selector))); + } else { + container.innerHTML = html; + append$1(content, slice.call(container.childNodes)); } + return content; + }; - var currentSame = currentStart === currentEnd; - var futureSame = futureStart === futureEnd; + // creates SVG fragment with a fallback for IE that needs SVG + // within the HTML content + var SVGFragment = hasContent ? function (node, html) { + var content = fragment(node); + var container = doc(node).createElementNS(SVG_NAMESPACE, 'svg'); + container.innerHTML = html; + append$1(content, slice.call(container.childNodes)); + return content; + } : function (node, html) { + var content = fragment(node); + var container = create(node, 'div'); + container.innerHTML = '' + html + ''; + append$1(content, slice.call(container.firstChild.childNodes)); + return content; + }; + + function Wire(childNodes) { + this.childNodes = childNodes; + this.length = childNodes.length; + this.first = childNodes[0]; + this.last = childNodes[this.length - 1]; + this._ = null; + } - // same list - if (currentSame && futureSame) return futureNodes; + // when a wire is inserted, all its nodes will follow + Wire.prototype.valueOf = function valueOf(different) { + var noFragment = this._ == null; + if (noFragment) this._ = fragment(this.first); + /* istanbul ignore else */ + if (noFragment || different) append$1(this._, this.childNodes); + return this._; + }; - // only stuff to add - if (currentSame && futureStart < futureEnd) { - append$1(get, parentNode, futureNodes, futureStart, futureEnd, next(get, currentNodes, currentStart, currentLength, before)); - return futureNodes; + // when a wire is removed, all its nodes must be removed as well + Wire.prototype.remove = function remove() { + this._ = null; + var first = this.first; + var last = this.last; + if (this.length === 2) { + last.parentNode.removeChild(last); + } else { + var range = doc(first).createRange(); + range.setStartBefore(this.childNodes[1]); + range.setEndAfter(last); + range.deleteContents(); } + return first; + }; - // only stuff to remove - if (futureSame && currentStart < currentEnd) { - remove(get, parentNode, currentNodes, currentStart, currentEnd); - return futureNodes; + // every template literal interpolation indicates + // a precise target in the DOM the template is representing. + // `

some ${'content'}

` + // hyperHTML finds only once per template literal, + // hence once per entire application life-cycle, + // all nodes that are related to interpolations. + // These nodes are stored as indexes used to retrieve, + // once per upgrade, nodes that will change on each future update. + // A path example is [2, 0, 1] representing the operation: + // node.childNodes[2].childNodes[0].childNodes[1] + // Attributes are addressed via their owner node and their name. + var createPath = function createPath(node) { + var path = []; + var parentNode = void 0; + switch (node.nodeType) { + case ELEMENT_NODE: + case DOCUMENT_FRAGMENT_NODE: + parentNode = node; + break; + case COMMENT_NODE: + parentNode = node.parentNode; + prepend(path, parentNode, node); + break; + default: + parentNode = node.ownerElement; + break; + } + for (node = parentNode; parentNode = parentNode.parentNode; node = parentNode) { + prepend(path, parentNode, node); } + return path; + }; - var currentChanges = currentEnd - currentStart; - var futureChanges = futureEnd - futureStart; - var i = -1; + var prepend = function prepend(path, parent, node) { + path.unshift(path.indexOf.call(parent.childNodes, node)); + }; - // 2 simple indels: the shortest sequence is a subsequence of the longest - if (currentChanges < futureChanges) { - i = indexOf(futureNodes, futureStart, futureEnd, currentNodes, currentStart, currentEnd, compare); - // inner diff - if (-1 < i) { - append$1(get, parentNode, futureNodes, futureStart, i, get(currentNodes[currentStart], 0)); - append$1(get, parentNode, futureNodes, i + currentChanges, futureEnd, next(get, currentNodes, currentEnd, currentLength, before)); - return futureNodes; - } - } - /* istanbul ignore else */ - else if (futureChanges < currentChanges) { - i = indexOf(currentNodes, currentStart, currentEnd, futureNodes, futureStart, futureEnd, compare); - // outer diff - if (-1 < i) { - remove(get, parentNode, currentNodes, currentStart, i); - remove(get, parentNode, currentNodes, i + futureChanges, currentEnd); - return futureNodes; - } + var Path = { + create: function create(type, node, name) { + return { type: type, name: name, node: node, path: createPath(node) }; + }, + find: function find(node, path) { + var length = path.length; + for (var i = 0; i < length; i++) { + node = node.childNodes[path[i]]; } - - // common case with one replacement for many nodes - // or many nodes replaced for a single one - /* istanbul ignore else */ - if (currentChanges < 2 || futureChanges < 2) { - append$1(get, parentNode, futureNodes, futureStart, futureEnd, get(currentNodes[currentStart], 0)); - remove(get, parentNode, currentNodes, currentStart, currentEnd); - return futureNodes; + return node; } + }; - // the half match diff part has been skipped in petit-dom - // https://github.com/yelouafi/petit-dom/blob/bd6f5c919b5ae5297be01612c524c40be45f14a7/src/vdom.js#L391-L397 - // accordingly, I think it's safe to skip in here too - // if one day it'll come out like the speediest thing ever to do - // then I might add it in here too + // from https://github.com/developit/preact/blob/33fc697ac11762a1cb6e71e9847670d047af7ce5/src/constants.js + var IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i; - // Extra: before going too fancy, what about reversed lists ? - // This should bail out pretty quickly if that's not the case. - if (currentChanges === futureChanges && isReversed(futureNodes, futureEnd, currentNodes, currentStart, currentEnd, compare)) { - append$1(get, parentNode, futureNodes, futureStart, futureEnd, next(get, currentNodes, currentEnd, currentLength, before)); - return futureNodes; + // style is handled as both string and object + // even if the target is an SVG element (consistency) + var Style = (function (node, original, isSVG) { + if (isSVG) { + var style = original.cloneNode(true); + style.value = ''; + node.setAttributeNode(style); + return update(style, isSVG); } + return update(node.style, isSVG); + }); - // last resort through a smart diff - smartDiff(get, parentNode, futureNodes, futureStart, futureEnd, futureChanges, currentNodes, currentStart, currentEnd, currentChanges, currentLength, compare, before); - - return futureNodes; - }; - - /* AUTOMATICALLY IMPORTED, DO NOT MODIFY */ - /*! (c) Andrea Giammarchi */ - function disconnected(poly) { - - var CONNECTED = 'connected'; - var DISCONNECTED = 'dis' + CONNECTED; - var Event = poly.Event; - var WeakSet = poly.WeakSet; - var notObserving = true; - var observer = new WeakSet(); - return function observe(node) { - if (notObserving) { - notObserving = !notObserving; - startObserving(node.ownerDocument); - } - observer.add(node); - return node; - }; - function startObserving(document) { - var dispatched = null; - try { - new MutationObserver(changes).observe(document, { subtree: true, childList: true }); - } catch (o_O) { - var timer = 0; - var records = []; - var reschedule = function reschedule(record) { - records.push(record); - clearTimeout(timer); - timer = setTimeout(function () { - changes(records.splice(timer = 0, records.length)); - }, 0); - }; - document.addEventListener('DOMNodeRemoved', function (event) { - reschedule({ addedNodes: [], removedNodes: [event.target] }); - }, true); - document.addEventListener('DOMNodeInserted', function (event) { - reschedule({ addedNodes: [event.target], removedNodes: [] }); - }, true); - } - function changes(records) { - dispatched = new Tracker(); - for (var record, length = records.length, i = 0; i < length; i++) { - record = records[i]; - dispatchAll(record.removedNodes, DISCONNECTED, CONNECTED); - dispatchAll(record.addedNodes, CONNECTED, DISCONNECTED); - } - dispatched = null; - } - function dispatchAll(nodes, type, counter) { - for (var node, event = new Event(type), length = nodes.length, i = 0; i < length; (node = nodes[i++]).nodeType === 1 && dispatchTarget(node, event, type, counter)) {} - } - function dispatchTarget(node, event, type, counter) { - if (observer.has(node) && !dispatched[type].has(node)) { - dispatched[counter].delete(node); - dispatched[type].add(node); - node.dispatchEvent(event); - /* - // The event is not bubbling (perf reason: should it?), - // hence there's no way to know if - // stop/Immediate/Propagation() was called. - // Should DOM Level 0 work at all? - // I say it's a YAGNI case for the time being, - // and easy to implement in user-land. - if (!event.cancelBubble) { - var fn = node['on' + type]; - if (fn) - fn.call(node, event); + // the update takes care or changing/replacing + // only properties that are different or + // in case of string, the whole node + var update = function update(style, isSVG) { + var oldType = void 0, + oldValue = void 0; + return function (newValue) { + switch (typeof newValue) { + case 'object': + if (newValue) { + if (oldType === 'object') { + if (!isSVG) { + if (oldValue !== newValue) { + for (var key in oldValue) { + if (!(key in newValue)) { + style[key] = ''; + } + } + } + } + } else { + if (isSVG) style.value = '';else style.cssText = ''; + } + var info = isSVG ? {} : style; + for (var _key in newValue) { + var value = newValue[_key]; + var styleValue = typeof value === 'number' && !IS_NON_DIMENSIONAL.test(_key) ? value + 'px' : value; + if (!isSVG && /^--/.test(_key)) info.setProperty(_key, styleValue);else info[_key] = styleValue; + } + oldType = 'object'; + if (isSVG) style.value = toStyle(oldValue = info);else oldValue = newValue; + break; } - */ - } - for (var children = node.children, length = children.length, i = 0; i < length; dispatchTarget(children[i++], event, type, counter)) {} - } - function Tracker() { - this[CONNECTED] = new WeakSet(); - this[DISCONNECTED] = new WeakSet(); + default: + if (oldValue != newValue) { + oldType = 'string'; + oldValue = newValue; + if (isSVG) style.value = newValue || '';else style.cssText = newValue || ''; + } + break; } + }; + }; + + var hyphen = /([^A-Z])([A-Z]+)/g; + var ized = function ized($0, $1, $2) { + return $1 + '-' + $2.toLowerCase(); + }; + var toStyle = function toStyle(object) { + var css = []; + for (var key in object) { + css.push(key.replace(hyphen, ized), ':', object[key], ';'); } - } + return css.join(''); + }; var document$1 = G.document; - var observe = disconnected({ Event: Event, WeakSet: WeakSet }); + var observe = disconnected({ Event: CustomEvent$1, WeakSet: WeakSet$1 }); // a basic dictionary used to filter already cached attributes // while looking for special hyperHTML values. @@ -1501,7 +1532,7 @@ var hyperHTML = (function (global) { // a weak collection of contexts that // are already known to hyperHTML - var bewitched = new WeakMap(); + var bewitched = new WeakMap$1(); // all unique template literals var templates = TemplateMap(); @@ -1565,7 +1596,7 @@ var hyperHTML = (function (global) { }; // all wires used per each context - var wires = new WeakMap(); + var wires = new WeakMap$1(); // A wire is a callback used as tag function // to lazily relate a generic object to a template literal. @@ -1604,7 +1635,7 @@ var hyperHTML = (function (global) { updates.apply(null, arguments); if (setup) { if (type === 'svg') { - append(content, slice.call(container.childNodes)); + append$1(content, slice.call(container.childNodes)); } wire = wireContent(content); } @@ -1675,8 +1706,8 @@ var hyperHTML = (function (global) { // i.e. those still targeting IE hyper._ = { global: G, - WeakMap: WeakMap, - WeakSet: WeakSet + WeakMap: WeakMap$1, + WeakSet: WeakSet$1 }; // the wire content is the lazy defined diff --git a/min.js b/min.js index ee9dc0d9..11204346 100644 --- a/min.js +++ b/min.js @@ -1,2 +1,3 @@ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){this.childNodes=e,this.length=e.length,this.first=e[0],this.last=e[this.length-1],this._=null}function r(){}function i(e){var t=Fe.get(this);return t&&t.template===Y(e)?a.apply(t.updates,arguments):o.apply(this,arguments),this}function o(e){e=Y(e);var t=Be.get(e)||u.call(this,e),n=U(this.ownerDocument,t.fragment),r=ze.create(n,t.paths);Fe.set(this,{template:e,updates:r}),a.apply(r,arguments),this.textContent="",this.appendChild(n)}function a(){for(var e=arguments.length,t=1;t\"'=]+",M="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",$="(?:=(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",_=new RegExp(M+L+$+"+)([ "+T+"]*/?>)","g"),D=new RegExp(M+L+$+"*)([ "+T+"]*/>)","g"),P=function(e,t){return R(e).createElement(t)},R=function(e){return e.ownerDocument||e},H=function(e){return R(e).createDocumentFragment()},W=function(e,t){return R(e).createTextNode(t)},z=H(document),F="append"in z,B="content"in P(document,"template");z.appendChild(W(z,"g")),z.appendChild(W(z,""));var Z=1===z.cloneNode(!0).childNodes.length,V="importNode"in document,G=F?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"+t+"",G(r,X.call(n.querySelectorAll(i)))}else n.innerHTML=t,G(r,X.call(n.childNodes));return r},ne=B?function(e,t){var n=H(e),r=R(e).createElementNS(s,"svg");return r.innerHTML=t,G(n,X.call(r.childNodes)),n}:function(e,t){var n=H(e),r=P(e,"div");return r.innerHTML=''+t+"",G(n,X.call(r.firstChild.childNodes)),n};n.prototype.valueOf=function(e){var t=null==this._;return t&&(this._=H(this.first)),(t||e)&&G(this._,this.childNodes),this._},n.prototype.remove=function(){this._=null;var e=this.first,t=this.last;if(2===this.length)t.parentNode.removeChild(t);else{var n=R(e).createRange();n.setStartBefore(this.childNodes[1]),n.setEndAfter(t),n.deleteContents()}return e};var re=function(e){var t=[],n=void 0;switch(e.nodeType){case 1:case 11:n=e;break;case 8:n=e.parentNode,ie(t,n,e);break;default:n=e.ownerElement}for(e=n;n=n.parentNode;e=n)ie(t,n,e);return t},ie=function(e,t,n){e.unshift(e.indexOf.call(t.childNodes,n))},oe={create:function(e,t,n){return{type:e,name:n,node:t,path:re(t)}},find:function(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var g=Array(l),b=f[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},Ne=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,f=void 0,s=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],f=-l;f<=l;f+=2){for(d=f===-l||f!==l&&h[p+f-1]=0;l--){for(;d>0&&s>0&&a(r[i+d-1],e[t+s-1]);)m[g--]=0,d--,s--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],f=d-s,f===-l||f!==l&&h[p+f-1]>>0;n"},Ge=new b,Ie=function(e,t){return null==e?qe(t||"html"):Je(e,t||"html")},qe=function(e){var t=void 0,n=void 0,r=void 0,o=void 0,a=void 0;return function(u){u=Y(u);var c=o!==u;return c&&(o=u,r=H(document),n="svg"===e?document.createElementNS(s,"svg"):r,a=i.bind(n)),a.apply(null,arguments),c&&("svg"===e&&G(r,X.call(n.childNodes)),t=Ke(r)),t}},Je=function(e,t){var n=t.indexOf(":"),r=Ge.get(e),i=t;return-1=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var b=Array(l),w=s[c];for(--n;w;){for(var y=w,N=y.newi,E=y.oldi;n>N;)b[--l]=1,--n;for(;a>E;)b[--l]=-1,--a;b[--l]=0,--n,--a,w=w.prev}for(;n>=t;)b[--l]=1,--n;for(;a>=o;)b[--l]=-1,--a;return b},k=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)m[g--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n\"'=]+",J="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",K="(?:=(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",Q=new RegExp(J+q+K+"+)([ "+I+"]*/?>)","g"),U=new RegExp(J+q+K+"*)([ "+I+"]*/>)","g"),X=function(e,t){return Y(e).createElement(t)},Y=function(e){return e.ownerDocument||e},ee=function(e){return Y(e).createDocumentFragment()},te=function(e,t){return Y(e).createTextNode(t)},ne=ee(document),re="append"in ne,ie="content"in X(document,"template");ne.appendChild(te(ne,"g")),ne.appendChild(te(ne,""));var oe=1===ne.cloneNode(!0).childNodes.length,ae="importNode"in document,ue=re?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"+t+"",ue(r,ve.call(n.querySelectorAll(i)))}else n.innerHTML=t,ue(r,ve.call(n.childNodes));return r},be=ie?function(e,t){var n=ee(e),r=Y(e).createElementNS(B,"svg");return r.innerHTML=t,ue(n,ve.call(r.childNodes)),n}:function(e,t){var n=ee(e),r=X(e,"div");return r.innerHTML=''+t+"",ue(n,ve.call(r.firstChild.childNodes)),n};n.prototype.valueOf=function(e){var t=null==this._;return t&&(this._=ee(this.first)),(t||e)&&ue(this._,this.childNodes),this._},n.prototype.remove=function(){this._=null;var e=this.first,t=this.last;if(2===this.length)t.parentNode.removeChild(t);else{var n=Y(e).createRange();n.setStartBefore(this.childNodes[1]),n.setEndAfter(t),n.deleteContents()}return e};var we=function(e){var t=[],n=void 0;switch(e.nodeType){case 1:case 11:n=e;break;case 8:n=e.parentNode,ye(t,n,e);break;default:n=e.ownerElement}for(e=n;n=n.parentNode;e=n)ye(t,n,e);return t},ye=function(e,t,n){e.unshift(e.indexOf.call(t.childNodes,n))},Ne={create:function(e,t,n){return{type:e,name:n,node:t,path:we(t)}},find:function(e,t){for(var n=t.length,r=0;r"},qe=new s,Je=function(e,t){return null==e?Ke(t||"html"):Qe(e,t||"html")},Ke=function(e){var t=void 0,n=void 0,r=void 0,o=void 0,a=void 0;return function(u){u=pe(u);var c=o!==u;return c&&(o=u,r=ee(document),n="svg"===e?document.createElementNS(B,"svg"):r,a=i.bind(n)),a.apply(null,arguments),c&&("svg"===e&&ue(r,ve.call(n.childNodes)),t=Ue(r)),t}},Qe=function(e,t){var n=t.indexOf(":"),r=qe.get(e),i=t;return-1\n _templateObject35 = _taggedTemplateLiteral(['

', '

'], ['

', '

']), _templateObject36 = _taggedTemplateLiteral([''], ['']), _templateObject37 = _taggedTemplateLiteral(['

'], ['

']), - _templateObject38 = _taggedTemplateLiteral([''], ['']), + _templateObject38 = _taggedTemplateLiteral([''], ['']), _templateObject39 = _taggedTemplateLiteral([''], ['']), _templateObject40 = _taggedTemplateLiteral(['\n '], ['\n ']), _templateObject41 = _taggedTemplateLiteral(['\n
First name: ', '
\n

'], ['\n
First name: ', '
\n

']), @@ -527,7 +527,15 @@ tressa.async(function (done) { return tressa.async(function (done) { var div = document.createElement('div'); document.body.appendChild(div); - hyperHTML.bind(div)(_templateObject38, function () { + hyperHTML.bind(div)(_templateObject38, function (event) { + if (/loaded|complete/.test(event.readyState)) setTimeout(function () { + tressa.assert(true, 'executed'); + done(); + }); + }, function () { + tressa.assert(true, 'executed'); + done(); + }, function () { tressa.assert(true, 'executed'); done(); }); @@ -849,7 +857,7 @@ tressa.async(function (done) { tressa.assert(div.querySelector('p').getAttribute('attr') === 'test', 'the

is defined'); p.render().click(); tressa.assert(p.clicked, 'the event worked'); - render(_templateObject11, [Rect.for({ x: 789, y: 123 })]); + render(_templateObject11, [hyperHTML.Component.for.call(Rect, { x: 789, y: 123 })]); tressa.assert(div.querySelector('rect').getAttribute('x') == '789', 'the for(state) worked'); }).then(function () { return tressa.async(function (done) { @@ -1115,7 +1123,7 @@ tressa.async(function (done) { tressa.assert(div.children[2].getAttribute('test') == "2", 'third node ok'); div = hyperHTML.wire()(_templateObject66); tressa.assert(div.children.length === 1, 'one svg'); - tressa.assert(div.children[0].children.length === 2, 'two paths'); + tressa.assert(div.querySelectorAll('path').length === 2, 'two paths'); }).then(function () { tressa.log('## '); function check(form) { @@ -1315,6 +1323,12 @@ tressa.async(function (done) { var a = document.createElement('div'); var b = document.createElement('div'); + var method = hyperHTML.Component.for; + if (!MenuSimple.for) { + MenuSimple.for = method; + MenuWeakMap.for = method; + MenuItem.for = method; + } hyperHTML.bind(a)(_templateObject11, MenuSimple.for(a).render({ items: [{ name: 'item 1' }, { name: 'item 2' }, { name: 'item 3' }] })); diff --git a/test/runner.js b/test/runner.js index 463ffdb4..641b0d0b 100644 --- a/test/runner.js +++ b/test/runner.js @@ -73,8 +73,6 @@ setTimeout(function () { createDocumentFragment.call(document); }; - global.WeakMap = global.WeakSet = void 0; - global.Event = function (type) { var e = global.document.createEvent('Event'); e.initEvent(type, false, false); diff --git a/test/test.js b/test/test.js index 3a09db44..6506a123 100644 --- a/test/test.js +++ b/test/test.js @@ -485,10 +485,24 @@ tressa.async(function (done) { return tressa.async(function (done) { var div = document.createElement('div'); document.body.appendChild(div); - hyperHTML.bind(div)``; + hyperHTML.bind(div)``; // in nodejs case if (!('onload' in document.defaultView)) { var evt = document.createEvent('Event'); @@ -816,7 +830,7 @@ tressa.async(function (done) { p.render().click(); tressa.assert(p.clicked, 'the event worked'); render`${[ - Rect.for({x: 789, y: 123}) + hyperHTML.Component.for.call(Rect, {x: 789, y: 123}) ]}`; tressa.assert(div.querySelector('rect').getAttribute('x') == '789', 'the for(state) worked'); }) @@ -1024,7 +1038,7 @@ tressa.async(function (done) { `; tressa.assert(div.children.length === 1, 'one svg'); - tressa.assert(div.children[0].children.length === 2, 'two paths'); + tressa.assert(div.querySelectorAll('path').length === 2, 'two paths'); }) .then(function () { tressa.log('## '); @@ -1184,6 +1198,12 @@ tressa.async(function (done) { } var a = document.createElement('div'); var b = document.createElement('div'); + var method = hyperHTML.Component.for; + if (!MenuSimple.for) { + MenuSimple.for = method; + MenuWeakMap.for = method; + MenuItem.for = method; + } hyperHTML.bind(a)`${MenuSimple.for(a).render({ items: [{name: 'item 1'}, {name: 'item 2'}, {name: 'item 3'}] })}`; diff --git a/umd.js b/umd.js index 60db51dd..028c0f9f 100644 --- a/umd.js +++ b/umd.js @@ -1,4 +1,5 @@ (function(A,G){if(typeof define=='function'&&define.amd)define([],G);else if(typeof module=='object'&&module.exports)module.exports=G();else A.hyperHTML=G()}(typeof self!='undefined'?self:this,function(){ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){this.childNodes=e,this.length=e.length,this.first=e[0],this.last=e[this.length-1],this._=null}function r(){}function i(e){var t=Fe.get(this);return t&&t.template===Y(e)?a.apply(t.updates,arguments):o.apply(this,arguments),this}function o(e){e=Y(e);var t=Be.get(e)||u.call(this,e),n=U(this.ownerDocument,t.fragment),r=ze.create(n,t.paths);Fe.set(this,{template:e,updates:r}),a.apply(r,arguments),this.textContent="",this.appendChild(n)}function a(){for(var e=arguments.length,t=1;t\"'=]+",M="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",$="(?:=(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",_=new RegExp(M+L+$+"+)([ "+T+"]*/?>)","g"),D=new RegExp(M+L+$+"*)([ "+T+"]*/>)","g"),P=function(e,t){return R(e).createElement(t)},R=function(e){return e.ownerDocument||e},H=function(e){return R(e).createDocumentFragment()},W=function(e,t){return R(e).createTextNode(t)},z=H(document),F="append"in z,B="content"in P(document,"template");z.appendChild(W(z,"g")),z.appendChild(W(z,""));var Z=1===z.cloneNode(!0).childNodes.length,V="importNode"in document,G=F?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"+t+"",G(r,X.call(n.querySelectorAll(i)))}else n.innerHTML=t,G(r,X.call(n.childNodes));return r},ne=B?function(e,t){var n=H(e),r=R(e).createElementNS(s,"svg");return r.innerHTML=t,G(n,X.call(r.childNodes)),n}:function(e,t){var n=H(e),r=P(e,"div");return r.innerHTML=''+t+"",G(n,X.call(r.firstChild.childNodes)),n};n.prototype.valueOf=function(e){var t=null==this._;return t&&(this._=H(this.first)),(t||e)&&G(this._,this.childNodes),this._},n.prototype.remove=function(){this._=null;var e=this.first,t=this.last;if(2===this.length)t.parentNode.removeChild(t);else{var n=R(e).createRange();n.setStartBefore(this.childNodes[1]),n.setEndAfter(t),n.deleteContents()}return e};var re=function(e){var t=[],n=void 0;switch(e.nodeType){case 1:case 11:n=e;break;case 8:n=e.parentNode,ie(t,n,e);break;default:n=e.ownerElement}for(e=n;n=n.parentNode;e=n)ie(t,n,e);return t},ie=function(e,t,n){e.unshift(e.indexOf.call(t.childNodes,n))},oe={create:function(e,t,n){return{type:e,name:n,node:t,path:re(t)}},find:function(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var g=Array(l),b=f[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},Ne=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,f=void 0,s=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],f=-l;f<=l;f+=2){for(d=f===-l||f!==l&&h[p+f-1]=0;l--){for(;d>0&&s>0&&a(r[i+d-1],e[t+s-1]);)m[g--]=0,d--,s--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],f=d-s,f===-l||f!==l&&h[p+f-1]>>0;n"},Ge=new b,Ie=function(e,t){return null==e?qe(t||"html"):Je(e,t||"html")},qe=function(e){var t=void 0,n=void 0,r=void 0,o=void 0,a=void 0;return function(u){u=Y(u);var c=o!==u;return c&&(o=u,r=H(document),n="svg"===e?document.createElementNS(s,"svg"):r,a=i.bind(n)),a.apply(null,arguments),c&&("svg"===e&&G(r,X.call(n.childNodes)),t=Ke(r)),t}},Je=function(e,t){var n=t.indexOf(":"),r=Ge.get(e),i=t;return-1=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var b=Array(l),w=s[c];for(--n;w;){for(var y=w,N=y.newi,E=y.oldi;n>N;)b[--l]=1,--n;for(;a>E;)b[--l]=-1,--a;b[--l]=0,--n,--a,w=w.prev}for(;n>=t;)b[--l]=1,--n;for(;a>=o;)b[--l]=-1,--a;return b},k=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)m[g--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n\"'=]+",J="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",K="(?:=(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",Q=new RegExp(J+q+K+"+)([ "+I+"]*/?>)","g"),U=new RegExp(J+q+K+"*)([ "+I+"]*/>)","g"),X=function(e,t){return Y(e).createElement(t)},Y=function(e){return e.ownerDocument||e},ee=function(e){return Y(e).createDocumentFragment()},te=function(e,t){return Y(e).createTextNode(t)},ne=ee(document),re="append"in ne,ie="content"in X(document,"template");ne.appendChild(te(ne,"g")),ne.appendChild(te(ne,""));var oe=1===ne.cloneNode(!0).childNodes.length,ae="importNode"in document,ue=re?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"+t+"",ue(r,ve.call(n.querySelectorAll(i)))}else n.innerHTML=t,ue(r,ve.call(n.childNodes));return r},be=ie?function(e,t){var n=ee(e),r=Y(e).createElementNS(B,"svg");return r.innerHTML=t,ue(n,ve.call(r.childNodes)),n}:function(e,t){var n=ee(e),r=X(e,"div");return r.innerHTML=''+t+"",ue(n,ve.call(r.firstChild.childNodes)),n};n.prototype.valueOf=function(e){var t=null==this._;return t&&(this._=ee(this.first)),(t||e)&&ue(this._,this.childNodes),this._},n.prototype.remove=function(){this._=null;var e=this.first,t=this.last;if(2===this.length)t.parentNode.removeChild(t);else{var n=Y(e).createRange();n.setStartBefore(this.childNodes[1]),n.setEndAfter(t),n.deleteContents()}return e};var we=function(e){var t=[],n=void 0;switch(e.nodeType){case 1:case 11:n=e;break;case 8:n=e.parentNode,ye(t,n,e);break;default:n=e.ownerElement}for(e=n;n=n.parentNode;e=n)ye(t,n,e);return t},ye=function(e,t,n){e.unshift(e.indexOf.call(t.childNodes,n))},Ne={create:function(e,t,n){return{type:e,name:n,node:t,path:we(t)}},find:function(e,t){for(var n=t.length,r=0;r"},qe=new s,Je=function(e,t){return null==e?Ke(t||"html"):Qe(e,t||"html")},Ke=function(e){var t=void 0,n=void 0,r=void 0,o=void 0,a=void 0;return function(u){u=pe(u);var c=o!==u;return c&&(o=u,r=ee(document),n="svg"===e?document.createElementNS(B,"svg"):r,a=i.bind(n)),a.apply(null,arguments),c&&("svg"===e&&ue(r,ve.call(n.childNodes)),t=Ue(r)),t}},Qe=function(e,t){var n=t.indexOf(":"),r=qe.get(e),i=t;return-1 Date: Sat, 24 Nov 2018 18:20:21 +0100 Subject: [PATCH 007/151] 2.18.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e8b70b81..0f73536e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hyperhtml", - "version": "2.17.2", + "version": "2.18.0", "description": "A Fast & Light Virtual DOM Alternative", "homepage": "https://viperhtml.js.org/hyper.html", "unpkg": "min.js", From d5ed48c7f2a2c9e3d53a73807ea2be93c9bfb9d6 Mon Sep 17 00:00:00 2001 From: Andrea Giammarchi Date: Tue, 27 Nov 2018 19:28:46 +0100 Subject: [PATCH 008/151] removed unnecessary build steps --- package.json | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/package.json b/package.json index 0f73536e..e176e585 100644 --- a/package.json +++ b/package.json @@ -70,20 +70,8 @@ "mv index.clean index.js" ], "cjs": [ - "$ disconnected", - "$ domdiff", "ascjs ./esm ./cjs" ], - "disconnected": [ - "echo '/* AUTOMATICALLY IMPORTED, DO NOT MODIFY */' > esm/3rd/disconnected.js", - "cat node_modules/disconnected/esm/index.js >> esm/3rd/disconnected.js" - ], - "domdiff": [ - "echo '/* AUTOMATICALLY IMPORTED, DO NOT MODIFY */' > esm/3rd/domdiff.js", - "cat node_modules/domdiff/esm/index.js >> esm/3rd/domdiff.js", - "echo '/* AUTOMATICALLY IMPORTED, DO NOT MODIFY */' > esm/3rd/utils.js", - "cat node_modules/domdiff/esm/utils.js >> esm/3rd/utils.js" - ], "size": { "gzip": [ [ From b994a7ca99979d54ad62ae648cc7ccb9d4a886fe Mon Sep 17 00:00:00 2001 From: Andrea Giammarchi Date: Wed, 28 Nov 2018 10:51:19 +0100 Subject: [PATCH 009/151] fixed coveralls script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e176e585..c391a0c5 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "$": "npm-dollar", "build": "npm run $ build", "bundle": "npm run $ bundle", - "coveralls": "coveralls", + "coveralls": "cat ./coverage/lcov.info | coveralls", "postinstall": "lightercollective", "test": "npm run $ test" }, From c05ba7f4dadb2f00affd7944386803f728e2f6a0 Mon Sep 17 00:00:00 2001 From: Lonnie Best Date: Thu, 29 Nov 2018 00:03:54 -0600 Subject: [PATCH 010/151] typo in comment. "ony" should be "only" --- esm/hyper/wire.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esm/hyper/wire.js b/esm/hyper/wire.js index fc41c91d..37c7a197 100644 --- a/esm/hyper/wire.js +++ b/esm/hyper/wire.js @@ -75,7 +75,7 @@ const weakly = (obj, type) => { // node wouldn't know which node was there // associated to the interpolation. // To prevent hyperHTML to forget about wired nodes, -// these are either returned as Array or, if there's ony one entry, +// these are either returned as Array or, if there's only one entry, // as single referenced node that won't disappear from the fragment. // The initial fragment, at this point, would be used as unique reference. const wireContent = node => { From a98f42b911822870cd70d6fdddec0a503854d56d Mon Sep 17 00:00:00 2001 From: Andrea Giammarchi Date: Wed, 28 Nov 2018 16:26:00 +0100 Subject: [PATCH 011/151] Introducing domtagger as external dependency In an ongoing attempt to refactor out all the bricks that make hyperHTML what it is, I have also removed all the unnecessary code that is taken care now by domtagger, which is 100% code covered a part, together with all other external dependencies. This MR also cleans up the test and its coverage, hoping to see the coveralls badge showing some number again. --- cjs/classes/Component.js | 6 +- cjs/classes/Wire.js | 3 +- cjs/hyper/render.js | 60 +- cjs/hyper/wire.js | 38 +- cjs/index.js | 14 +- cjs/objects/Style.js | 2 +- cjs/objects/Updates.js | 661 ++++++--------- cjs/shared/constants.js | 22 - cjs/shared/easy-dom.js | 2 - cjs/shared/features-detection.js | 23 +- cjs/shared/utils.js | 196 +---- esm.js | 6 +- esm/.eslintrc | 3 +- esm/classes/Wire.js | 3 +- esm/hyper/render.js | 58 +- esm/hyper/wire.js | 32 +- esm/objects/Engine.js | 45 -- esm/objects/Path.js | 57 -- esm/objects/Style.js | 2 +- esm/objects/Updates.js | 646 ++++++--------- esm/shared/constants.js | 13 - esm/shared/easy-dom.js | 5 - esm/shared/features-detection.js | 20 - esm/shared/re.js | 20 - esm/shared/utils.js | 188 +---- index.js | 1299 +++++++++++++++--------------- min.js | 6 +- package.json | 42 +- test/ie/test/test.js | 2 +- test/index.html | 4 + test/runner.js | 11 +- test/test.js | 4 +- umd.js | 6 +- 33 files changed, 1272 insertions(+), 2227 deletions(-) delete mode 100644 esm/objects/Engine.js delete mode 100644 esm/objects/Path.js delete mode 100644 esm/shared/easy-dom.js delete mode 100644 esm/shared/features-detection.js delete mode 100644 esm/shared/re.js diff --git a/cjs/classes/Component.js b/cjs/classes/Component.js index 7e5c299c..ebe3ffa4 100644 --- a/cjs/classes/Component.js +++ b/cjs/classes/Component.js @@ -1,7 +1,7 @@ 'use strict'; -const CustomEvent = (m => m.__esModule ? m.default : m)(require('@ungap/custom-event')); -const Map = (m => m.__esModule ? m.default : m)(require('@ungap/essential-map')); -const WeakMap = (m => m.__esModule ? m.default : m)(require('@ungap/weakmap')); +const CustomEvent = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/custom-event')); +const Map = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/essential-map')); +const WeakMap = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/weakmap')); // hyperHTML.Component is a very basic class // able to create Custom Elements like components diff --git a/cjs/classes/Wire.js b/cjs/classes/Wire.js index da8d4e34..2d1983ee 100644 --- a/cjs/classes/Wire.js +++ b/cjs/classes/Wire.js @@ -1,6 +1,5 @@ 'use strict'; -const { append } = require('../shared/utils.js'); -const { doc, fragment } = require('../shared/easy-dom.js'); +const { append, doc, fragment } = require('../shared/utils.js'); function Wire(childNodes) { this.childNodes = childNodes; diff --git a/cjs/hyper/render.js b/cjs/hyper/render.js index d457ef9b..8e1d4339 100644 --- a/cjs/hyper/render.js +++ b/cjs/hyper/render.js @@ -1,24 +1,14 @@ 'use strict'; -const WeakMap = (m => m.__esModule ? m.default : m)(require('@ungap/weakmap')); +const WeakMap = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/weakmap')); +const unique = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/template-literal')); -const {UIDC, VOID_ELEMENTS} = require('../shared/constants.js'); -const Updates = (m => m.__esModule ? m.default : m)(require('../objects/Updates.js')); -const { - createFragment, - importNode, - unique, - TemplateMap -} = require('../shared/utils.js'); - -const {selfClosing} = require('../shared/re.js'); +const {OWNER_SVG_ELEMENT} = require('../shared/constants.js'); +const {Tagger} = require('../objects/Updates.js'); // a weak collection of contexts that // are already known to hyperHTML const bewitched = new WeakMap; -// all unique template literals -const templates = TemplateMap(); - // better known as hyper.bind(node), the render is // the main tag function in charge of fully upgrading // or simply updating, contexts used as hyperHTML targets. @@ -26,7 +16,7 @@ const templates = TemplateMap(); function render(template) { const wicked = bewitched.get(this); if (wicked && wicked.template === unique(template)) { - update.apply(wicked.updates, arguments); + wicked.tagger.apply(null, arguments); } else { upgrade.apply(this, arguments); } @@ -39,43 +29,11 @@ function render(template) { // to the current context, and render it after cleaning the context up function upgrade(template) { template = unique(template); - const info = templates.get(template) || - createTemplate.call(this, template); - const fragment = importNode(this.ownerDocument, info.fragment); - const updates = Updates.create(fragment, info.paths); - bewitched.set(this, {template, updates}); - update.apply(updates, arguments); + const type = OWNER_SVG_ELEMENT in this ? 'svg' : 'html'; + const tagger = new Tagger(type); + bewitched.set(this, {tagger, template}); this.textContent = ''; - this.appendChild(fragment); -} - -// an update simply loops over all mapped DOM operations -function update() { - const length = arguments.length; - for (let i = 1; i < length; i++) { - this[i - 1](arguments[i]); - } -} - -// a template can be used to create a document fragment -// aware of all interpolations and with a list -// of paths used to find once those nodes that need updates, -// no matter if these are attributes, text nodes, or regular one -function createTemplate(template) { - const paths = []; - const html = template.join(UIDC).replace(SC_RE, SC_PLACE); - const fragment = createFragment(this, html); - Updates.find(fragment, paths, template.slice()); - const info = {fragment, paths}; - templates.set(template, info); - return info; + this.appendChild(tagger.apply(null, arguments)); } -// some node could be special though, like a custom element -// with a self closing tag, which should work through these changes. -const SC_RE = selfClosing; -const SC_PLACE = ($0, $1, $2) => { - return VOID_ELEMENTS.test($1) ? $0 : ('<' + $1 + $2 + '>'); -}; - Object.defineProperty(exports, '__esModule', {value: true}).default = render; diff --git a/cjs/hyper/wire.js b/cjs/hyper/wire.js index 9ec20815..8719ab59 100644 --- a/cjs/hyper/wire.js +++ b/cjs/hyper/wire.js @@ -1,12 +1,12 @@ 'use strict'; -const WeakMap = (m => m.__esModule ? m.default : m)(require('@ungap/weakmap')); -const trim = (m => m.__esModule ? m.default : m)(require('@ungap/trim')); +const WeakMap = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/weakmap')); +const unique = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/template-literal')); +const trim = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/trim')); -const {ELEMENT_NODE, SVG_NAMESPACE} = require('../shared/constants.js'); -const {fragment} = require('../shared/easy-dom.js'); -const {append, slice, unique} = require('../shared/utils.js'); -const Wire = (m => m.__esModule ? m.default : m)(require('../classes/Wire.js')); -const render = (m => m.__esModule ? m.default : m)(require('./render.js')); +const {ELEMENT_NODE} = require('../shared/constants.js'); +const Wire = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('../classes/Wire.js')); + +const {Tagger} = require('../objects/Updates.js'); // all wires used per each context const wires = new WeakMap; @@ -31,24 +31,15 @@ const wire = (obj, type) => obj == null ? // In few words, a wire content is like an invisible parent node // in charge of updating its content like a bound element would do. const content = type => { - let wire, container, content, template, updates; + let wire, tagger, template; return function (statics) { statics = unique(statics); - let setup = template !== statics; - if (setup) { + if (template !== statics) { template = statics; - content = fragment(document); - container = type === 'svg' ? - document.createElementNS(SVG_NAMESPACE, 'svg') : - content; - updates = render.bind(container); - } - updates.apply(null, arguments); - if (setup) { - if (type === 'svg') { - append(content, slice.call(container.childNodes)); - } - wire = wireContent(content); + tagger = new Tagger(type); + wire = wireContent(tagger.apply(tagger, arguments)); + } else { + tagger.apply(tagger, arguments); } return wire; }; @@ -65,7 +56,8 @@ const weakly = (obj, type) => { id = type.slice(i + 1); type = type.slice(0, i) || 'html'; } - if (!wire) wires.set(obj, wire = {}); + if (!wire) + wires.set(obj, wire = {}); return wire[id] || (wire[id] = content(type)); }; diff --git a/cjs/index.js b/cjs/index.js index 182e154d..88bb594b 100644 --- a/cjs/index.js +++ b/cjs/index.js @@ -1,16 +1,16 @@ 'use strict'; /*! (c) Andrea Giammarchi (ISC) */ -const WeakMap = (m => m.__esModule ? m.default : m)(require('@ungap/weakmap')); -const WeakSet = (m => m.__esModule ? m.default : m)(require('@ungap/essential-weakset')); +const WeakMap = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/weakmap')); +const WeakSet = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/essential-weakset')); -const diff = (m => m.__esModule ? m.default : m)(require('domdiff')); -const Component = (m => m.__esModule ? m.default : m)(require('./classes/Component.js')); +const diff = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('domdiff')); +const Component = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('./classes/Component.js')); const {setup} = require('./classes/Component.js'); -const Intent = (m => m.__esModule ? m.default : m)(require('./objects/Intent.js')); +const Intent = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('./objects/Intent.js')); const {observe} = require('./objects/Updates.js'); -const wire = (m => m.__esModule ? m.default : m)(require('./hyper/wire.js')); +const wire = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('./hyper/wire.js')); const {content, weakly} = require('./hyper/wire.js'); -const render = (m => m.__esModule ? m.default : m)(require('./hyper/render.js')); +const render = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('./hyper/render.js')); const { G } = require('./shared/constants.js'); // all functions are self bound to the right context diff --git a/cjs/objects/Style.js b/cjs/objects/Style.js index debf986f..9b177723 100644 --- a/cjs/objects/Style.js +++ b/cjs/objects/Style.js @@ -79,4 +79,4 @@ const toStyle = object => { css.push(key.replace(hyphen, ized), ':', object[key], ';'); } return css.join(''); -}; \ No newline at end of file +}; diff --git a/cjs/objects/Updates.js b/cjs/objects/Updates.js index 853ac657..a75244b4 100644 --- a/cjs/objects/Updates.js +++ b/cjs/objects/Updates.js @@ -1,33 +1,27 @@ 'use strict'; -const CustomEvent = (m => m.__esModule ? m.default : m)(require('@ungap/custom-event')); -const WeakSet = (m => m.__esModule ? m.default : m)(require('@ungap/essential-weakset')); -const isArray = (m => m.__esModule ? m.default : m)(require('@ungap/is-array')); -const trim = (m => m.__esModule ? m.default : m)(require('@ungap/trim')); +const CustomEvent = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/custom-event')); +const WeakSet = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/essential-weakset')); +const isArray = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/is-array')); -const disconnected = (m => m.__esModule ? m.default : m)(require('disconnected')); -const domdiff = (m => m.__esModule ? m.default : m)(require('domdiff')); +const createContent = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/create-content')); +const disconnected = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('disconnected')); +const domdiff = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('domdiff')); +const domtagger = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('domtagger')); const { - CONNECTED, DISCONNECTED, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, ELEMENT_NODE, TEXT_NODE, OWNER_SVG_ELEMENT, SHOULD_USE_TEXT_CONTENT, G, UID, UIDC + CONNECTED, DISCONNECTED, DOCUMENT_FRAGMENT_NODE, OWNER_SVG_ELEMENT } = require('../shared/constants.js'); -const Component = (m => m.__esModule ? m.default : m)(require('../classes/Component.js')); -const Wire = (m => m.__esModule ? m.default : m)(require('../classes/Wire.js')); -const Path = (m => m.__esModule ? m.default : m)(require('./Path.js')); -const Style = (m => m.__esModule ? m.default : m)(require('./Style.js')); -const Intent = (m => m.__esModule ? m.default : m)(require('./Intent.js')); -// see /^script$/i.test(nodeName) bit down here -// import { create as createElement, text } from '../shared/easy-dom.js'; -const { text } = require('../shared/easy-dom.js'); -const { createFragment, slice } = require('../shared/utils.js'); +const Component = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('../classes/Component.js')); +const Wire = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('../classes/Wire.js')); +const Style = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('./Style.js')); +const Intent = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('./Intent.js')); +const { slice, text } = require('../shared/utils.js'); -const { document } = G; const observe = disconnected({Event: CustomEvent, WeakSet}); -// a basic dictionary used to filter already cached attributes -// while looking for special hyperHTML values. -function Cache() {} -Cache.prototype = Object.create(null); +exports.Tagger = Tagger; +exports.observe = observe; // returns an intent to explicitly inject content as html const asHTML = html => ({html}); @@ -48,154 +42,10 @@ const asNode = (item, i) => { } // returns true if domdiff can handle the value -const canDiff = value => 'ELEMENT_NODE' in value || -value instanceof Wire || -value instanceof Component; - -// updates are created once per context upgrade -// within the main render function (../hyper/render.js) -// These are an Array of callbacks to invoke passing -// each interpolation value. -// Updates can be related to any kind of content, -// attributes, or special text-only cases such + + + + + \ No newline at end of file diff --git a/umd.js b/umd.js index b6caf5e7..5d78e511 100644 --- a/umd.js +++ b/umd.js @@ -1,5 +1,5 @@ (function(A,G){if(typeof define=='function'&&define.amd)define([],G);else if(typeof module=='object'&&module.exports)module.exports=G();else A.hyperHTML=G()}(typeof self!='undefined'?self:this,function(){ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){return e.join(ee).replace(he,o).replace(fe,r)}function r(e,t,n,r){return"<"+t+n.replace(de,i)+r}function i(e,t,n){return t+(n||'"')+Y+(n||'"')}function o(e,t,n){return ae.test(t)?e:"<"+t+n+">"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case re:case ne:t=e;break;case te:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var y=b,w=y.newi,N=y.oldi;n>w;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},P=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,h=void 0,d=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,d=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(h=s===-l||s!==l&&d[p+s-1]=0;l--){for(;h>0&&f>0&&a(r[i+h-1],e[t+f-1]);)g[m--]=0,h--,f--;if(!l)break;p=l-1,d=l?c[l-1]:[0,0],s=h-f,s===-l||s!==l&&d[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),U=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o\"'=]+",le="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",se="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",fe=new RegExp(le+ce+se+"+)([ "+ue+"]*/?>)","g"),he=new RegExp(le+ce+se+"*)([ "+ue+"]*/>)","g"),de=new RegExp("("+ce+"\\s*=\\s*)(['\"]?)"+ee+"\\2","gi"),ve="".trim||function(){return String(this).replace(/^\s+|\s+/g,"")},pe=new N,ge=new N,me=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),be=e.defaultView,ye="ownerSVGElement",we=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),Ne=function(e){return e.ownerDocument||e},xe=function(e){return Ne(e).createDocumentFragment()},Ee=function(e,t){return Ne(e).createTextNode(t)},ke="append"in xe(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case ne:case te:t=e;break;case ee:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var y=b,w=y.newi,N=y.oldi;n>w;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},P=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),U=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==X)})(e.createElement("template"))||(X="_dt: "+X.slice(1,-1)+";");var Y="\x3c!--"+X+"--\x3e",ee=8,te=11,ne=1,re=3,ie=/^(?:style|textarea)$/i,oe=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ae=" \\f\\n\\r\\t",ue="[ "+ae+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ce="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",le="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",se=new RegExp(ce+ue+le+"+)([ "+ae+"]*/?>)","g"),fe=new RegExp(ce+ue+le+"*)([ "+ae+"]*/>)","g"),de=new RegExp("("+ue+"\\s*=\\s*)(['\"]?)"+Y+"\\2","gi"),he="".trim||function(){return String(this).replace(/^\s+|\s+/g,"")},ve=new N,pe=new N,ge=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),me=e.defaultView,be="ownerSVGElement",ye=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),we=function(e){return e.ownerDocument||e},Ne=function(e){return we(e).createDocumentFragment()},xe=function(e,t){return we(e).createTextNode(t)},Ee="append"in Ne(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r Date: Tue, 4 Dec 2018 21:48:37 +0700 Subject: [PATCH 025/151] 2.20.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b8599ae1..b8eea5c1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hyperhtml", - "version": "2.20.1", + "version": "2.20.2", "description": "A Fast & Light Virtual DOM Alternative", "homepage": "https://viperhtml.js.org/hyper.html", "unpkg": "min.js", From 9f08ce566dda718c950bbbfaa971af6657f6ce34 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Wed, 5 Dec 2018 00:36:11 +0000 Subject: [PATCH 026/151] fix(package): update @ungap/custom-event to version 0.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b8eea5c1..1620ff96 100644 --- a/package.json +++ b/package.json @@ -152,7 +152,7 @@ }, "dependencies": { "@ungap/create-content": "^0.1.1", - "@ungap/custom-event": "^0.1.2", + "@ungap/custom-event": "^0.2.0", "@ungap/essential-map": "^0.1.7", "@ungap/essential-weakset": "^0.1.2", "@ungap/is-array": "^0.1.1", From 9d5e60346af5d61bf97555f7accf3eb1b3312164 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sun, 9 Dec 2018 13:02:06 +0000 Subject: [PATCH 027/151] chore(package): update rollup-plugin-node-resolve to version 4.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1620ff96..a9cb5c40 100644 --- a/package.json +++ b/package.json @@ -140,7 +140,7 @@ "npm-dollar": "^2.1.3", "rollup": "^0.67.0", "rollup-plugin-babel": "^3.0.7", - "rollup-plugin-node-resolve": "^3.4.0", + "rollup-plugin-node-resolve": "^4.0.0", "tressa": "^0.3.1", "uglify-js": "^2.8.29" }, From 31bd895cd1e2f2d871ae9ac81d27a8f5b6297794 Mon Sep 17 00:00:00 2001 From: Mike Samuel Date: Mon, 10 Dec 2018 14:28:23 -0500 Subject: [PATCH 028/151] fixes typo: s/tha/that/ --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 00231d81..6a7b5a6a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ A **Fast & Light Virtual DOM Alternative** available for [Node.js](https://viper ## Neverland 🌈🦄 -If you like React hooks concept, don't miss this little wrap tha adds 0._something_ overhead to the already lightweight hyperHTML, bringing in very similar concepts. +If you like React hooks concept, don't miss this little wrap that adds 0._something_ overhead to the already lightweight hyperHTML, bringing in very similar concepts. [Blog Post](https://medium.com/@WebReflection/neverland-the-hyperhtmls-hook-a0c3e11324bb) From 6853f6be1ae38efd65e15e70e65a82aff67d8f3b Mon Sep 17 00:00:00 2001 From: Andrea Giammarchi Date: Sun, 16 Dec 2018 10:19:27 +0800 Subject: [PATCH 029/151] Fix #311 (maybe) & Fix #312 --- esm.js | 6 +-- index.js | 99 +++++++++++++++++++++++++++++++++++--------- min.js | 6 +-- package.json | 2 +- test/ie/test/test.js | 2 +- test/test.js | 2 +- umd.js | 6 +-- 7 files changed, 91 insertions(+), 32 deletions(-) diff --git a/esm.js b/esm.js index 83c26cc7..5bd3e3f9 100644 --- a/esm.js +++ b/esm.js @@ -1,5 +1,5 @@ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){return e.join(Y).replace(fe,o).replace(se,r)}function r(e,t,n,r){return"<"+t+n.replace(de,i)+r}function i(e,t,n){return t+(n||'"')+X+(n||'"')}function o(e,t,n){return oe.test(t)?e:"<"+t+n+">"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case ne:case te:t=e;break;case ee:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var y=b,w=y.newi,N=y.oldi;n>w;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},P=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),U=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==X)})(e.createElement("template"))||(X="_dt: "+X.slice(1,-1)+";");var Y="\x3c!--"+X+"--\x3e",ee=8,te=11,ne=1,re=3,ie=/^(?:style|textarea)$/i,oe=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ae=" \\f\\n\\r\\t",ue="[ "+ae+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ce="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",le="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",se=new RegExp(ce+ue+le+"+)([ "+ae+"]*/?>)","g"),fe=new RegExp(ce+ue+le+"*)([ "+ae+"]*/>)","g"),de=new RegExp("("+ue+"\\s*=\\s*)(['\"]?)"+Y+"\\2","gi"),he="".trim||function(){return String(this).replace(/^\s+|\s+/g,"")},ve=new N,pe=new N,ge=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),me=e.defaultView,be="ownerSVGElement",ye=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),we=function(e){return e.ownerDocument||e},Ne=function(e){return we(e).createDocumentFragment()},xe=function(e,t){return we(e).createTextNode(t)},Ee="append"in Ne(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case oe:case ie:t=e;break;case re:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},W=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),X=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Y=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==te)})(e.createElement("template"))||(te="_dt: "+te.slice(1,-1)+";");var ne="\x3c!--"+te+"--\x3e",re=8,ie=11,oe=1,ae=3,ue=/^(?:style|textarea)$/i,ce=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,le=" \\f\\n\\r\\t",se="[ "+le+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",fe="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",de="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",he=new RegExp(fe+se+de+"+)([ "+le+"]*/?>)","g"),ve=new RegExp(fe+se+de+"*)([ "+le+"]*/>)","g"),pe=new RegExp("("+se+"\\s*=\\s*)(['\"]?)"+ne+"\\2","gi"),ge=new x,me=new x,be=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),we=e.defaultView,ye="ownerSVGElement",Ne=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),xe=function(e){return e.ownerDocument||e},Ee=function(e){return xe(e).createDocumentFragment()},ke=function(e,t){return xe(e).createTextNode(t)},Ce="append"in Ee(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r'; + childNodes = template.querySelectorAll(selector); + } else { + template.innerHTML = html; + childNodes = template.childNodes; + } + append(content, childNodes); + return content; + }; + + return function createContent(markup, type) { + return (type === 'svg' ? createSVG : createHTML)(markup); + }; + + function append(root, childNodes) { + var length = childNodes.length; + while (length--) { + root.appendChild(childNodes[0]); + } + } + + function create(element) { + return element === FRAGMENT ? document.createDocumentFragment() : document.createElementNS('http://www.w3.org/1999/xhtml', element); + } + + // it could use createElementNS when hasNode is there + // but this fallback is equally fast and easier to maintain + // it is also battle tested already in all IE + function createSVG(svg) { + var content = create(FRAGMENT); + var template = create('div'); + template.innerHTML = '' + svg + ''; + append(content, template.firstChild.childNodes); + return content; + } + }(document); + /*! (c) Andrea Giammarchi - ISC */ var importNode = function (document, appendChild, cloneNode, createTextNode, importNode) { var native = importNode in document; @@ -817,6 +864,10 @@ var hyperHTML = (function (document) { }; }(document, 'appendChild', 'cloneNode', 'createTextNode', 'importNode'); + var trim = ''.trim || function () { + return String(this).replace(/^\s+|\s+/g, ''); + }; + // Custom var UID = '-' + Math.random().toFixed(6) + '%'; // Edge issue! @@ -862,10 +913,6 @@ var hyperHTML = (function (document) { return VOID_ELEMENTS.test($1) ? $0 : '<' + $1 + $2 + '>'; } - var trim = ''.trim || function () { - return String(this).replace(/^\s+|\s+/g, ''); - }; - function create(type, node, name) { return { type: type, name: name, node: node, path: createPath(node) }; } @@ -1008,7 +1055,8 @@ var hyperHTML = (function (document) { var markup = sanitize(template); var transform = options.transform; if (transform) markup = transform(markup); - var content = createContent(markup, options.type); + var content = createContent$1(markup, options.type); + cleanContent(content); var holes = []; parse(content, holes, template.slice(0)); var info = { @@ -1071,6 +1119,17 @@ var hyperHTML = (function (document) { }; } + function cleanContent(fragment) { + var childNodes = fragment.childNodes; + var i = childNodes.length; + while (i--) { + var child = childNodes[i]; + if (child.nodeType !== 1 && trim.call(child.textContent).length === 0) { + fragment.removeChild(child); + } + } + } + /*! (c) Andrea Giammarchi - ISC */ var hyperStyle = function () { // from https://github.com/developit/preact/blob/33fc697ac11762a1cb6e71e9847670d047af7ce5/src/varants.js diff --git a/min.js b/min.js index 2cad76a6..619490dd 100644 --- a/min.js +++ b/min.js @@ -1,3 +1,3 @@ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){return e.join(Y).replace(fe,o).replace(se,r)}function r(e,t,n,r){return"<"+t+n.replace(de,i)+r}function i(e,t,n){return t+(n||'"')+X+(n||'"')}function o(e,t,n){return oe.test(t)?e:"<"+t+n+">"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case ne:case te:t=e;break;case ee:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var y=b,w=y.newi,N=y.oldi;n>w;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},P=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),U=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==X)})(e.createElement("template"))||(X="_dt: "+X.slice(1,-1)+";");var Y="\x3c!--"+X+"--\x3e",ee=8,te=11,ne=1,re=3,ie=/^(?:style|textarea)$/i,oe=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ae=" \\f\\n\\r\\t",ue="[ "+ae+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ce="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",le="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",se=new RegExp(ce+ue+le+"+)([ "+ae+"]*/?>)","g"),fe=new RegExp(ce+ue+le+"*)([ "+ae+"]*/>)","g"),de=new RegExp("("+ue+"\\s*=\\s*)(['\"]?)"+Y+"\\2","gi"),he="".trim||function(){return String(this).replace(/^\s+|\s+/g,"")},ve=new N,pe=new N,ge=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),me=e.defaultView,be="ownerSVGElement",ye=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),we=function(e){return e.ownerDocument||e},Ne=function(e){return we(e).createDocumentFragment()},xe=function(e,t){return we(e).createTextNode(t)},Ee="append"in Ne(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case oe:case ie:t=e;break;case re:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},W=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),X=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Y=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==te)})(e.createElement("template"))||(te="_dt: "+te.slice(1,-1)+";");var ne="\x3c!--"+te+"--\x3e",re=8,ie=11,oe=1,ae=3,ue=/^(?:style|textarea)$/i,ce=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,le=" \\f\\n\\r\\t",se="[ "+le+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",fe="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",de="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",he=new RegExp(fe+se+de+"+)([ "+le+"]*/?>)","g"),ve=new RegExp(fe+se+de+"*)([ "+le+"]*/>)","g"),pe=new RegExp("("+se+"\\s*=\\s*)(['\"]?)"+ne+"\\2","gi"),ge=new x,me=new x,be=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),we=e.defaultView,ye="ownerSVGElement",Ne=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),xe=function(e){return e.ownerDocument||e},Ee=function(e){return xe(e).createDocumentFragment()},ke=function(e,t){return xe(e).createTextNode(t)},Ce="append"in Ee(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r1 /.test(wrap.innerHTML), 'virtual content in between'); + tressa.assert(/^\s*1\s*$/.test(wrap.innerHTML), 'virtual content in between'); var last = hyperHTML.wire(); empty = function empty(style) { diff --git a/test/test.js b/test/test.js index ae739f34..a9d5407e 100644 --- a/test/test.js +++ b/test/test.js @@ -455,7 +455,7 @@ tressa.async(function (done) { tressa.assert(wrap.textContent === ' 1 ', 'text in between'); hyperHTML.bind(wrap)`
${1}
`; - tressa.assert(/ 1 /.test(wrap.innerHTML), 'virtual content in between'); + tressa.assert(/^\s*1\s*$/.test(wrap.innerHTML), 'virtual content in between'); let last = hyperHTML.wire(); empty = function (style) { diff --git a/umd.js b/umd.js index 5d78e511..28e09c14 100644 --- a/umd.js +++ b/umd.js @@ -1,5 +1,5 @@ (function(A,G){if(typeof define=='function'&&define.amd)define([],G);else if(typeof module=='object'&&module.exports)module.exports=G();else A.hyperHTML=G()}(typeof self!='undefined'?self:this,function(){ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){return e.join(Y).replace(fe,o).replace(se,r)}function r(e,t,n,r){return"<"+t+n.replace(de,i)+r}function i(e,t,n){return t+(n||'"')+X+(n||'"')}function o(e,t,n){return oe.test(t)?e:"<"+t+n+">"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case ne:case te:t=e;break;case ee:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var y=b,w=y.newi,N=y.oldi;n>w;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},P=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),U=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==X)})(e.createElement("template"))||(X="_dt: "+X.slice(1,-1)+";");var Y="\x3c!--"+X+"--\x3e",ee=8,te=11,ne=1,re=3,ie=/^(?:style|textarea)$/i,oe=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ae=" \\f\\n\\r\\t",ue="[ "+ae+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ce="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",le="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",se=new RegExp(ce+ue+le+"+)([ "+ae+"]*/?>)","g"),fe=new RegExp(ce+ue+le+"*)([ "+ae+"]*/>)","g"),de=new RegExp("("+ue+"\\s*=\\s*)(['\"]?)"+Y+"\\2","gi"),he="".trim||function(){return String(this).replace(/^\s+|\s+/g,"")},ve=new N,pe=new N,ge=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),me=e.defaultView,be="ownerSVGElement",ye=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),we=function(e){return e.ownerDocument||e},Ne=function(e){return we(e).createDocumentFragment()},xe=function(e,t){return we(e).createTextNode(t)},Ee="append"in Ne(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case oe:case ie:t=e;break;case re:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},W=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),X=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Y=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==te)})(e.createElement("template"))||(te="_dt: "+te.slice(1,-1)+";");var ne="\x3c!--"+te+"--\x3e",re=8,ie=11,oe=1,ae=3,ue=/^(?:style|textarea)$/i,ce=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,le=" \\f\\n\\r\\t",se="[ "+le+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",fe="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",de="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",he=new RegExp(fe+se+de+"+)([ "+le+"]*/?>)","g"),ve=new RegExp(fe+se+de+"*)([ "+le+"]*/>)","g"),pe=new RegExp("("+se+"\\s*=\\s*)(['\"]?)"+ne+"\\2","gi"),ge=new x,me=new x,be=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),we=e.defaultView,ye="ownerSVGElement",Ne=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),xe=function(e){return e.ownerDocument||e},Ee=function(e){return xe(e).createDocumentFragment()},ke=function(e,t){return xe(e).createTextNode(t)},Ce="append"in Ee(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r Date: Sun, 16 Dec 2018 10:19:33 +0800 Subject: [PATCH 030/151] 2.21.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 789fa75f..575f27e4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hyperhtml", - "version": "2.20.2", + "version": "2.21.0", "description": "A Fast & Light Virtual DOM Alternative", "homepage": "https://viperhtml.js.org/hyper.html", "unpkg": "min.js", From b28d46c70f4a24ab820d9faa44cad554ef9d5247 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sun, 16 Dec 2018 10:29:54 +0000 Subject: [PATCH 031/151] chore(package): update rollup to version 0.68.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 575f27e4..82b17839 100644 --- a/package.json +++ b/package.json @@ -138,7 +138,7 @@ "coveralls": "^3.0.2", "istanbul": "^0.4.5", "npm-dollar": "^2.1.3", - "rollup": "^0.67.0", + "rollup": "^0.68.0", "rollup-plugin-babel": "^3.0.7", "rollup-plugin-node-resolve": "^4.0.0", "tressa": "^0.3.1", From 7086b09b7f07bd4f6a50788197c2f48f7b73e765 Mon Sep 17 00:00:00 2001 From: Andrea Giammarchi Date: Mon, 17 Dec 2018 10:03:47 +0800 Subject: [PATCH 032/151] removed unnecessary checks due cleaner output produced by domtagger --- cjs/hyper/wire.js | 21 +++++---------------- esm.js | 2 +- esm/hyper/wire.js | 21 +++++---------------- index.js | 17 ++--------------- min.js | 2 +- umd.js | 2 +- 6 files changed, 15 insertions(+), 50 deletions(-) diff --git a/cjs/hyper/wire.js b/cjs/hyper/wire.js index 5965186c..d2d6f895 100644 --- a/cjs/hyper/wire.js +++ b/cjs/hyper/wire.js @@ -1,12 +1,10 @@ 'use strict'; const WeakMap = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/weakmap')); -const trim = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/trim')); -const {ELEMENT_NODE} = require('../shared/constants.js'); const Wire = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('../classes/Wire.js')); const {Tagger} = require('../objects/Updates.js'); -const {reArguments} = require('../shared/utils.js'); +const {reArguments, slice} = require('../shared/utils.js'); // all wires used per each context const wires = new WeakMap; @@ -69,24 +67,15 @@ const weakly = (obj, type) => { // stay associated with the original interpolation. // To prevent hyperHTML from forgetting about a fragment's sub-nodes, // fragments are instead returned as an Array of nodes or, if there's only one entry, -// as a single referenced node which, unlike framents, will indeed persist +// as a single referenced node which, unlike fragments, will indeed persist // wire content throughout multiple renderings. // The initial fragment, at this point, would be used as unique reference to this // array of nodes or to this single referenced node. const wireContent = node => { const childNodes = node.childNodes; - const length = childNodes.length; - const wireNodes = []; - for (let i = 0; i < length; i++) { - let child = childNodes[i]; - if ( - child.nodeType === ELEMENT_NODE || - trim.call(child.textContent).length !== 0 - ) { - wireNodes.push(child); - } - } - return wireNodes.length === 1 ? wireNodes[0] : new Wire(wireNodes); + return childNodes.length === 1 ? + childNodes[0] : + new Wire(slice.call(childNodes, 0)); }; exports.content = content; diff --git a/esm.js b/esm.js index 5bd3e3f9..7b7c9c0d 100644 --- a/esm.js +++ b/esm.js @@ -1,5 +1,5 @@ /*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){return e.join(ne).replace(ve,o).replace(he,r)}function r(e,t,n,r){return"<"+t+n.replace(pe,i)+r}function i(e,t,n){return t+(n||'"')+te+(n||'"')}function o(e,t,n){return ce.test(t)?e:"<"+t+n+">"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case oe:case ie:t=e;break;case re:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},W=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),X=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Y=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==te)})(e.createElement("template"))||(te="_dt: "+te.slice(1,-1)+";");var ne="\x3c!--"+te+"--\x3e",re=8,ie=11,oe=1,ae=3,ue=/^(?:style|textarea)$/i,ce=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,le=" \\f\\n\\r\\t",se="[ "+le+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",fe="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",de="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",he=new RegExp(fe+se+de+"+)([ "+le+"]*/?>)","g"),ve=new RegExp(fe+se+de+"*)([ "+le+"]*/>)","g"),pe=new RegExp("("+se+"\\s*=\\s*)(['\"]?)"+ne+"\\2","gi"),ge=new x,me=new x,be=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),we=e.defaultView,ye="ownerSVGElement",Ne=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),xe=function(e){return e.ownerDocument||e},Ee=function(e){return xe(e).createDocumentFragment()},ke=function(e,t){return xe(e).createTextNode(t)},Ce="append"in Ee(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r { // stay associated with the original interpolation. // To prevent hyperHTML from forgetting about a fragment's sub-nodes, // fragments are instead returned as an Array of nodes or, if there's only one entry, -// as a single referenced node which, unlike framents, will indeed persist +// as a single referenced node which, unlike fragments, will indeed persist // wire content throughout multiple renderings. // The initial fragment, at this point, would be used as unique reference to this // array of nodes or to this single referenced node. const wireContent = node => { const childNodes = node.childNodes; - const length = childNodes.length; - const wireNodes = []; - for (let i = 0; i < length; i++) { - let child = childNodes[i]; - if ( - child.nodeType === ELEMENT_NODE || - trim.call(child.textContent).length !== 0 - ) { - wireNodes.push(child); - } - } - return wireNodes.length === 1 ? wireNodes[0] : new Wire(wireNodes); + return childNodes.length === 1 ? + childNodes[0] : + new Wire(slice.call(childNodes, 0)); }; export { content, weakly }; diff --git a/index.js b/index.js index 7f6c61a2..53b24c42 100644 --- a/index.js +++ b/index.js @@ -1202,11 +1202,6 @@ var hyperHTML = (function (document) { }(); var G = document.defaultView; - - // Node.CONSTANTS - // 'cause some engine has no global Node defined - // (i.e. Node, NativeScript, basicHTML ... ) - var ELEMENT_NODE$1 = 1; var DOCUMENT_FRAGMENT_NODE$1 = 11; // SVG related constants @@ -1641,21 +1636,13 @@ var hyperHTML = (function (document) { // stay associated with the original interpolation. // To prevent hyperHTML from forgetting about a fragment's sub-nodes, // fragments are instead returned as an Array of nodes or, if there's only one entry, - // as a single referenced node which, unlike framents, will indeed persist + // as a single referenced node which, unlike fragments, will indeed persist // wire content throughout multiple renderings. // The initial fragment, at this point, would be used as unique reference to this // array of nodes or to this single referenced node. var wireContent = function wireContent(node) { var childNodes = node.childNodes; - var length = childNodes.length; - var wireNodes = []; - for (var i = 0; i < length; i++) { - var child = childNodes[i]; - if (child.nodeType === ELEMENT_NODE$1 || trim.call(child.textContent).length !== 0) { - wireNodes.push(child); - } - } - return wireNodes.length === 1 ? wireNodes[0] : new Wire(wireNodes); + return childNodes.length === 1 ? childNodes[0] : new Wire(slice.call(childNodes, 0)); }; // a weak collection of contexts that diff --git a/min.js b/min.js index 619490dd..6efa6d44 100644 --- a/min.js +++ b/min.js @@ -1,3 +1,3 @@ /*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){return e.join(ne).replace(ve,o).replace(he,r)}function r(e,t,n,r){return"<"+t+n.replace(pe,i)+r}function i(e,t,n){return t+(n||'"')+te+(n||'"')}function o(e,t,n){return ce.test(t)?e:"<"+t+n+">"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case oe:case ie:t=e;break;case re:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},W=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),X=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Y=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==te)})(e.createElement("template"))||(te="_dt: "+te.slice(1,-1)+";");var ne="\x3c!--"+te+"--\x3e",re=8,ie=11,oe=1,ae=3,ue=/^(?:style|textarea)$/i,ce=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,le=" \\f\\n\\r\\t",se="[ "+le+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",fe="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",de="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",he=new RegExp(fe+se+de+"+)([ "+le+"]*/?>)","g"),ve=new RegExp(fe+se+de+"*)([ "+le+"]*/>)","g"),pe=new RegExp("("+se+"\\s*=\\s*)(['\"]?)"+ne+"\\2","gi"),ge=new x,me=new x,be=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),we=e.defaultView,ye="ownerSVGElement",Ne=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),xe=function(e){return e.ownerDocument||e},Ee=function(e){return xe(e).createDocumentFragment()},ke=function(e,t){return xe(e).createTextNode(t)},Ce="append"in Ee(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case oe:case ie:t=e;break;case re:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},W=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),X=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Y=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==te)})(e.createElement("template"))||(te="_dt: "+te.slice(1,-1)+";");var ne="\x3c!--"+te+"--\x3e",re=8,ie=11,oe=1,ae=3,ue=/^(?:style|textarea)$/i,ce=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,le=" \\f\\n\\r\\t",se="[ "+le+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",fe="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",de="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",he=new RegExp(fe+se+de+"+)([ "+le+"]*/?>)","g"),ve=new RegExp(fe+se+de+"*)([ "+le+"]*/>)","g"),pe=new RegExp("("+se+"\\s*=\\s*)(['\"]?)"+ne+"\\2","gi"),ge=new x,me=new x,be=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),we=e.defaultView,ye="ownerSVGElement",Ne=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),xe=function(e){return e.ownerDocument||e},Ee=function(e){return xe(e).createDocumentFragment()},ke=function(e,t){return xe(e).createTextNode(t)},Ce="append"in Ee(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r Date: Mon, 17 Dec 2018 10:29:08 +0800 Subject: [PATCH 033/151] using latest domtagger --- esm.js | 6 +++--- index.js | 14 ++++++++++++-- min.js | 6 +++--- package.json | 3 +-- umd.js | 6 +++--- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/esm.js b/esm.js index 7b7c9c0d..9f8913f7 100644 --- a/esm.js +++ b/esm.js @@ -1,5 +1,5 @@ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){return e.join(ne).replace(ve,o).replace(he,r)}function r(e,t,n,r){return"<"+t+n.replace(pe,i)+r}function i(e,t,n){return t+(n||'"')+te+(n||'"')}function o(e,t,n){return ce.test(t)?e:"<"+t+n+">"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case oe:case ie:t=e;break;case re:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},W=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),X=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Y=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==te)})(e.createElement("template"))||(te="_dt: "+te.slice(1,-1)+";");var ne="\x3c!--"+te+"--\x3e",re=8,ie=11,oe=1,ae=3,ue=/^(?:style|textarea)$/i,ce=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,le=" \\f\\n\\r\\t",se="[ "+le+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",fe="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",de="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",he=new RegExp(fe+se+de+"+)([ "+le+"]*/?>)","g"),ve=new RegExp(fe+se+de+"*)([ "+le+"]*/>)","g"),pe=new RegExp("("+se+"\\s*=\\s*)(['\"]?)"+ne+"\\2","gi"),ge=new x,me=new x,be=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),we=e.defaultView,ye="ownerSVGElement",Ne=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),xe=function(e){return e.ownerDocument||e},Ee=function(e){return xe(e).createDocumentFragment()},ke=function(e,t){return xe(e).createTextNode(t)},Ce="append"in Ee(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case oe:case ie:ge=-1,t=e;break;case re:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},W=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),X=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Y=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==te)})(e.createElement("template"))||(te="_dt: "+te.slice(1,-1)+";");var ne="\x3c!--"+te+"--\x3e",re=8,ie=11,oe=1,ae=3,ue=/^(?:style|textarea)$/i,ce=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,le=" \\f\\n\\r\\t",se="[ "+le+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",fe="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",de="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",he=new RegExp(fe+se+de+"+)([ "+le+"]*/?>)","g"),ve=new RegExp(fe+se+de+"*)([ "+le+"]*/>)","g"),pe=new RegExp("("+se+"\\s*=\\s*)(['\"]?)"+ne+"\\2","gi"),ge=-1,me=new x,be=new x,we=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),ye=e.defaultView,Ne="ownerSVGElement",xe=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),Ee=function(e){return e.ownerDocument||e},ke=function(e){return Ee(e).createDocumentFragment()},Ce=function(e,t){return Ee(e).createTextNode(t)},Me="append"in ke(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r'; } + var index = -1; + function create(type, node, name) { return { type: type, name: name, node: node, path: createPath(node) }; } @@ -923,6 +925,7 @@ var hyperHTML = (function (document) { switch (node.nodeType) { case ELEMENT_NODE: case DOCUMENT_FRAGMENT_NODE: + index = -1; parentNode = node; break; case COMMENT_NODE: @@ -951,7 +954,7 @@ var hyperHTML = (function (document) { var length = childNodes.length; var i = 0; while (i < length) { - var child = childNodes[i++]; + var child = childNodes[index = i++]; switch (child.nodeType) { case ELEMENT_NODE: parseAttributes(child, paths, parts); @@ -1004,7 +1007,9 @@ var hyperHTML = (function (document) { /* istanbul ignore next */ attributes[realName.toLowerCase()]; cache.set(name, value); + var currentIndex = index; paths.push(create('attr', value, realName)); + index = currentIndex; } remove.push(attribute); } @@ -1043,7 +1048,12 @@ var hyperHTML = (function (document) { } function prepend(path, parent, node) { - path.unshift(path.indexOf.call(parent.childNodes, node)); + // the first index represent the node position + // after that, it needs to be found. + // this speeds up repeated holes on the same template literal + // avoiding accessing the childNodes when the index is already known + path.unshift(index < 0 ? path.indexOf.call(parent.childNodes, node) : index); + index = -1; } // globals diff --git a/min.js b/min.js index 6efa6d44..ee00a14f 100644 --- a/min.js +++ b/min.js @@ -1,3 +1,3 @@ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){return e.join(ne).replace(ve,o).replace(he,r)}function r(e,t,n,r){return"<"+t+n.replace(pe,i)+r}function i(e,t,n){return t+(n||'"')+te+(n||'"')}function o(e,t,n){return ce.test(t)?e:"<"+t+n+">"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case oe:case ie:t=e;break;case re:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},W=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),X=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Y=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==te)})(e.createElement("template"))||(te="_dt: "+te.slice(1,-1)+";");var ne="\x3c!--"+te+"--\x3e",re=8,ie=11,oe=1,ae=3,ue=/^(?:style|textarea)$/i,ce=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,le=" \\f\\n\\r\\t",se="[ "+le+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",fe="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",de="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",he=new RegExp(fe+se+de+"+)([ "+le+"]*/?>)","g"),ve=new RegExp(fe+se+de+"*)([ "+le+"]*/>)","g"),pe=new RegExp("("+se+"\\s*=\\s*)(['\"]?)"+ne+"\\2","gi"),ge=new x,me=new x,be=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),we=e.defaultView,ye="ownerSVGElement",Ne=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),xe=function(e){return e.ownerDocument||e},Ee=function(e){return xe(e).createDocumentFragment()},ke=function(e,t){return xe(e).createTextNode(t)},Ce="append"in Ee(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case oe:case ie:ge=-1,t=e;break;case re:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},W=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),X=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Y=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==te)})(e.createElement("template"))||(te="_dt: "+te.slice(1,-1)+";");var ne="\x3c!--"+te+"--\x3e",re=8,ie=11,oe=1,ae=3,ue=/^(?:style|textarea)$/i,ce=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,le=" \\f\\n\\r\\t",se="[ "+le+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",fe="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",de="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",he=new RegExp(fe+se+de+"+)([ "+le+"]*/?>)","g"),ve=new RegExp(fe+se+de+"*)([ "+le+"]*/>)","g"),pe=new RegExp("("+se+"\\s*=\\s*)(['\"]?)"+ne+"\\2","gi"),ge=-1,me=new x,be=new x,we=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),ye=e.defaultView,Ne="ownerSVGElement",xe=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),Ee=function(e){return e.ownerDocument||e},ke=function(e){return Ee(e).createDocumentFragment()},Ce=function(e,t){return Ee(e).createTextNode(t)},Me="append"in ke(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case oe:case ie:t=e;break;case re:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},W=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),X=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Y=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==te)})(e.createElement("template"))||(te="_dt: "+te.slice(1,-1)+";");var ne="\x3c!--"+te+"--\x3e",re=8,ie=11,oe=1,ae=3,ue=/^(?:style|textarea)$/i,ce=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,le=" \\f\\n\\r\\t",se="[ "+le+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",fe="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",de="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",he=new RegExp(fe+se+de+"+)([ "+le+"]*/?>)","g"),ve=new RegExp(fe+se+de+"*)([ "+le+"]*/>)","g"),pe=new RegExp("("+se+"\\s*=\\s*)(['\"]?)"+ne+"\\2","gi"),ge=new x,me=new x,be=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),we=e.defaultView,ye="ownerSVGElement",Ne=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),xe=function(e){return e.ownerDocument||e},Ee=function(e){return xe(e).createDocumentFragment()},ke=function(e,t){return xe(e).createTextNode(t)},Ce="append"in Ee(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case oe:case ie:ge=-1,t=e;break;case re:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},W=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),X=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Y=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==te)})(e.createElement("template"))||(te="_dt: "+te.slice(1,-1)+";");var ne="\x3c!--"+te+"--\x3e",re=8,ie=11,oe=1,ae=3,ue=/^(?:style|textarea)$/i,ce=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,le=" \\f\\n\\r\\t",se="[ "+le+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",fe="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",de="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",he=new RegExp(fe+se+de+"+)([ "+le+"]*/?>)","g"),ve=new RegExp(fe+se+de+"*)([ "+le+"]*/>)","g"),pe=new RegExp("("+se+"\\s*=\\s*)(['\"]?)"+ne+"\\2","gi"),ge=-1,me=new x,be=new x,we=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),ye=e.defaultView,Ne="ownerSVGElement",xe=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),Ee=function(e){return e.ownerDocument||e},ke=function(e){return Ee(e).createDocumentFragment()},Ce=function(e,t){return Ee(e).createTextNode(t)},Me="append"in ke(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r Date: Mon, 17 Dec 2018 10:29:26 +0800 Subject: [PATCH 034/151] 2.22.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4a4bcccb..628a997c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hyperhtml", - "version": "2.21.0", + "version": "2.22.0", "description": "A Fast & Light Virtual DOM Alternative", "homepage": "https://viperhtml.js.org/hyper.html", "unpkg": "min.js", From 6423cd1daa212afca753b8fd0a14c816f7d5c3e6 Mon Sep 17 00:00:00 2001 From: Andrea Giammarchi Date: Mon, 17 Dec 2018 12:11:51 +0700 Subject: [PATCH 035/151] using latest domtagger --- esm.js | 6 ++--- index.js | 62 ++++++++++++---------------------------------------- min.js | 6 ++--- package.json | 2 +- umd.js | 6 ++--- 5 files changed, 24 insertions(+), 58 deletions(-) diff --git a/esm.js b/esm.js index 9f8913f7..76875a34 100644 --- a/esm.js +++ b/esm.js @@ -1,5 +1,5 @@ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){return e.join(ne).replace(ve,o).replace(he,r)}function r(e,t,n,r){return"<"+t+n.replace(pe,i)+r}function i(e,t,n){return t+(n||'"')+te+(n||'"')}function o(e,t,n){return ce.test(t)?e:"<"+t+n+">"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case oe:case ie:ge=-1,t=e;break;case re:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},W=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),X=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Y=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==te)})(e.createElement("template"))||(te="_dt: "+te.slice(1,-1)+";");var ne="\x3c!--"+te+"--\x3e",re=8,ie=11,oe=1,ae=3,ue=/^(?:style|textarea)$/i,ce=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,le=" \\f\\n\\r\\t",se="[ "+le+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",fe="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",de="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",he=new RegExp(fe+se+de+"+)([ "+le+"]*/?>)","g"),ve=new RegExp(fe+se+de+"*)([ "+le+"]*/>)","g"),pe=new RegExp("("+se+"\\s*=\\s*)(['\"]?)"+ne+"\\2","gi"),ge=-1,me=new x,be=new x,we=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),ye=e.defaultView,Ne="ownerSVGElement",xe=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),Ee=function(e){return e.ownerDocument||e},ke=function(e){return Ee(e).createDocumentFragment()},Ce=function(e,t){return Ee(e).createTextNode(t)},Me="append"in ke(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"}function a(e,t,n,r){return{name:r,node:t,path:n,type:e}}function u(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},O=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Q=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),U=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==Y)})(e.createElement("template"))||(Y="_dt: "+Y.slice(1,-1)+";");var ee="\x3c!--"+Y+"--\x3e",te=8,ne=1,re=3,ie=/^(?:style|textarea)$/i,oe=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ae=" \\f\\n\\r\\t",ue="[ "+ae+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ce="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",le="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",se=new RegExp(ce+ue+le+"+)([ "+ae+"]*/?>)","g"),fe=new RegExp(ce+ue+le+"*)([ "+ae+"]*/>)","g"),de=new RegExp("("+ue+"\\s*=\\s*)(['\"]?)"+ee+"\\2","gi"),he=new y,ve=new y,pe=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),ge=e.defaultView,me="ownerSVGElement",be=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),we=function(e){return e.ownerDocument||e},ye=function(e){return we(e).createDocumentFragment()},Ne=function(e,t){return we(e).createTextNode(t)},xe="append"in ye(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r'; } - var index = -1; - - function create(type, node, name) { - return { type: type, name: name, node: node, path: createPath(node) }; - } - - function createPath(node) { - var parentNode; - var path = []; - switch (node.nodeType) { - case ELEMENT_NODE: - case DOCUMENT_FRAGMENT_NODE: - index = -1; - parentNode = node; - break; - case COMMENT_NODE: - parentNode = node.parentNode; - prepend(path, parentNode, node); - break; - default: - parentNode = node.ownerElement; - break; - } - while (parentNode = (node = parentNode).parentNode) { - prepend(path, parentNode, node); - }return path; + function create(type, node, path, name) { + return { name: name, node: node, path: path, type: type }; } function find(node, path) { @@ -949,25 +924,26 @@ var hyperHTML = (function (document) { }return node; } - function parse(node, paths, parts) { + function parse(node, holes, parts, path) { var childNodes = node.childNodes; var length = childNodes.length; var i = 0; while (i < length) { - var child = childNodes[index = i++]; + var child = childNodes[i]; switch (child.nodeType) { case ELEMENT_NODE: - parseAttributes(child, paths, parts); - parse(child, paths, parts); + var childPath = path.concat(i); + parseAttributes(child, holes, parts, childPath); + parse(child, holes, parts, childPath); break; case COMMENT_NODE: if (child.textContent === UID) { parts.shift(); - paths.push( + holes.push( // basicHTML or other non standard engines // might end up having comments in nodes // where they shouldn't, hence this check. - SHOULD_USE_TEXT_CONTENT.test(node.nodeName) ? create('text', node) : create('any', child)); + SHOULD_USE_TEXT_CONTENT.test(node.nodeName) ? create('text', node, path) : create('any', child, path.concat(i))); } break; case TEXT_NODE: @@ -978,14 +954,15 @@ var hyperHTML = (function (document) { /* istanbul ignore if */ if (SHOULD_USE_TEXT_CONTENT.test(node.nodeName) && trim.call(child.textContent) === UIDC) { parts.shift(); - paths.push(create('text', node)); + holes.push(create('text', node, path)); } break; } + i++; } } - function parseAttributes(node, paths, parts) { + function parseAttributes(node, holes, parts, path) { var cache = new Map$1(); var attributes = node.attributes; var remove = []; @@ -1007,9 +984,7 @@ var hyperHTML = (function (document) { /* istanbul ignore next */ attributes[realName.toLowerCase()]; cache.set(name, value); - var currentIndex = index; - paths.push(create('attr', value, realName)); - index = currentIndex; + holes.push(create('attr', value, path, realName)); } remove.push(attribute); } @@ -1047,15 +1022,6 @@ var hyperHTML = (function (document) { } } - function prepend(path, parent, node) { - // the first index represent the node position - // after that, it needs to be found. - // this speeds up repeated holes on the same template literal - // avoiding accessing the childNodes when the index is already known - path.unshift(index < 0 ? path.indexOf.call(parent.childNodes, node) : index); - index = -1; - } - // globals var parsed = new WeakMap$1(); @@ -1068,7 +1034,7 @@ var hyperHTML = (function (document) { var content = createContent$1(markup, options.type); cleanContent(content); var holes = []; - parse(content, holes, template.slice(0)); + parse(content, holes, template.slice(0), []); var info = { content: content, updates: function updates(content) { diff --git a/min.js b/min.js index ee00a14f..59da25ed 100644 --- a/min.js +++ b/min.js @@ -1,3 +1,3 @@ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){return e.join(ne).replace(ve,o).replace(he,r)}function r(e,t,n,r){return"<"+t+n.replace(pe,i)+r}function i(e,t,n){return t+(n||'"')+te+(n||'"')}function o(e,t,n){return ce.test(t)?e:"<"+t+n+">"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case oe:case ie:ge=-1,t=e;break;case re:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},W=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),X=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Y=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==te)})(e.createElement("template"))||(te="_dt: "+te.slice(1,-1)+";");var ne="\x3c!--"+te+"--\x3e",re=8,ie=11,oe=1,ae=3,ue=/^(?:style|textarea)$/i,ce=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,le=" \\f\\n\\r\\t",se="[ "+le+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",fe="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",de="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",he=new RegExp(fe+se+de+"+)([ "+le+"]*/?>)","g"),ve=new RegExp(fe+se+de+"*)([ "+le+"]*/>)","g"),pe=new RegExp("("+se+"\\s*=\\s*)(['\"]?)"+ne+"\\2","gi"),ge=-1,me=new x,be=new x,we=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),ye=e.defaultView,Ne="ownerSVGElement",xe=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),Ee=function(e){return e.ownerDocument||e},ke=function(e){return Ee(e).createDocumentFragment()},Ce=function(e,t){return Ee(e).createTextNode(t)},Me="append"in ke(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"}function a(e,t,n,r){return{name:r,node:t,path:n,type:e}}function u(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},O=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Q=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),U=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==Y)})(e.createElement("template"))||(Y="_dt: "+Y.slice(1,-1)+";");var ee="\x3c!--"+Y+"--\x3e",te=8,ne=1,re=3,ie=/^(?:style|textarea)$/i,oe=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ae=" \\f\\n\\r\\t",ue="[ "+ae+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ce="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",le="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",se=new RegExp(ce+ue+le+"+)([ "+ae+"]*/?>)","g"),fe=new RegExp(ce+ue+le+"*)([ "+ae+"]*/>)","g"),de=new RegExp("("+ue+"\\s*=\\s*)(['\"]?)"+ee+"\\2","gi"),he=new y,ve=new y,pe=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),ge=e.defaultView,me="ownerSVGElement",be=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),we=function(e){return e.ownerDocument||e},ye=function(e){return we(e).createDocumentFragment()},Ne=function(e,t){return we(e).createTextNode(t)},xe="append"in ye(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"}function a(e,t,n){return{type:e,name:n,node:t,path:u(t)}}function u(e){var t,n=[];switch(e.nodeType){case oe:case ie:ge=-1,t=e;break;case re:t=e.parentNode,f(n,t,e);break;default:t=e.ownerElement}for(;t=(e=t).parentNode;)f(n,t,e);return n}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},W=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),X=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Y=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==te)})(e.createElement("template"))||(te="_dt: "+te.slice(1,-1)+";");var ne="\x3c!--"+te+"--\x3e",re=8,ie=11,oe=1,ae=3,ue=/^(?:style|textarea)$/i,ce=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,le=" \\f\\n\\r\\t",se="[ "+le+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",fe="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",de="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",he=new RegExp(fe+se+de+"+)([ "+le+"]*/?>)","g"),ve=new RegExp(fe+se+de+"*)([ "+le+"]*/>)","g"),pe=new RegExp("("+se+"\\s*=\\s*)(['\"]?)"+ne+"\\2","gi"),ge=-1,me=new x,be=new x,we=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),ye=e.defaultView,Ne="ownerSVGElement",xe=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),Ee=function(e){return e.ownerDocument||e},ke=function(e){return Ee(e).createDocumentFragment()},Ce=function(e,t){return Ee(e).createTextNode(t)},Me="append"in ke(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"}function a(e,t,n,r){return{name:r,node:t,path:n,type:e}}function u(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},O=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Q=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),U=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==Y)})(e.createElement("template"))||(Y="_dt: "+Y.slice(1,-1)+";");var ee="\x3c!--"+Y+"--\x3e",te=8,ne=1,re=3,ie=/^(?:style|textarea)$/i,oe=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ae=" \\f\\n\\r\\t",ue="[ "+ae+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ce="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",le="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",se=new RegExp(ce+ue+le+"+)([ "+ae+"]*/?>)","g"),fe=new RegExp(ce+ue+le+"*)([ "+ae+"]*/>)","g"),de=new RegExp("("+ue+"\\s*=\\s*)(['\"]?)"+ee+"\\2","gi"),he=new y,ve=new y,pe=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),ge=e.defaultView,me="ownerSVGElement",be=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),we=function(e){return e.ownerDocument||e},ye=function(e){return we(e).createDocumentFragment()},Ne=function(e,t){return we(e).createTextNode(t)},xe="append"in ye(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r Date: Mon, 17 Dec 2018 12:11:54 +0700 Subject: [PATCH 036/151] 2.22.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9cada166..552f5cbb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hyperhtml", - "version": "2.22.0", + "version": "2.22.1", "description": "A Fast & Light Virtual DOM Alternative", "homepage": "https://viperhtml.js.org/hyper.html", "unpkg": "min.js", From cfe1b5cbf343a2a3b46cd8bb2a74dd9563be156d Mon Sep 17 00:00:00 2001 From: Andrea Giammarchi Date: Mon, 17 Dec 2018 16:13:39 +0700 Subject: [PATCH 037/151] Fix #315 - include same dependencies once --- cjs/index.js | 2 - cjs/objects/Updates.js | 2 +- cjs/shared/constants.js | 3 - esm.js | 6 +- esm/index.js | 2 - esm/objects/Updates.js | 2 +- esm/shared/constants.js | 2 - index.js | 673 ++++++++++++++++++++++++---------------- min.js | 6 +- package.json | 23 +- rollup.config.js | 10 +- umd.js | 6 +- 12 files changed, 420 insertions(+), 317 deletions(-) diff --git a/cjs/index.js b/cjs/index.js index 96a17441..04ed734a 100644 --- a/cjs/index.js +++ b/cjs/index.js @@ -11,7 +11,6 @@ const {observe, Tagger} = require('./objects/Updates.js'); const wire = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('./hyper/wire.js')); const {content, weakly} = require('./hyper/wire.js'); const render = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('./hyper/render.js')); -const { G } = require('./shared/constants.js'); // all functions are self bound to the right context // you can do the following @@ -35,7 +34,6 @@ hyper.wire = wire; // that don't necessarily need upfront polyfills // i.e. those still targeting IE hyper._ = { - global: G, WeakMap, WeakSet }; diff --git a/cjs/objects/Updates.js b/cjs/objects/Updates.js index bd45002a..dda5a991 100644 --- a/cjs/objects/Updates.js +++ b/cjs/objects/Updates.js @@ -2,8 +2,8 @@ const CustomEvent = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/custom-event')); const WeakSet = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/essential-weakset')); const isArray = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/is-array')); - const createContent = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/create-content')); + const disconnected = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('disconnected')); const domdiff = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('domdiff')); const domtagger = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('domtagger')); diff --git a/cjs/shared/constants.js b/cjs/shared/constants.js index 9aafa3be..ebe14667 100644 --- a/cjs/shared/constants.js +++ b/cjs/shared/constants.js @@ -1,7 +1,4 @@ 'use strict'; -const G = document.defaultView; -exports.G = G; - // Node.CONSTANTS // 'cause some engine has no global Node defined // (i.e. Node, NativeScript, basicHTML ... ) diff --git a/esm.js b/esm.js index 76875a34..cf2346de 100644 --- a/esm.js +++ b/esm.js @@ -1,5 +1,5 @@ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){return e.join(ee).replace(fe,o).replace(se,r)}function r(e,t,n,r){return"<"+t+n.replace(de,i)+r}function i(e,t,n){return t+(n||'"')+Y+(n||'"')}function o(e,t,n){return oe.test(t)?e:"<"+t+n+">"}function a(e,t,n,r){return{name:r,node:t,path:n,type:e}}function u(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},O=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Q=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),U=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==Y)})(e.createElement("template"))||(Y="_dt: "+Y.slice(1,-1)+";");var ee="\x3c!--"+Y+"--\x3e",te=8,ne=1,re=3,ie=/^(?:style|textarea)$/i,oe=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ae=" \\f\\n\\r\\t",ue="[ "+ae+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ce="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",le="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",se=new RegExp(ce+ue+le+"+)([ "+ae+"]*/?>)","g"),fe=new RegExp(ce+ue+le+"*)([ "+ae+"]*/>)","g"),de=new RegExp("("+ue+"\\s*=\\s*)(['\"]?)"+ee+"\\2","gi"),he=new y,ve=new y,pe=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),ge=e.defaultView,me="ownerSVGElement",be=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),we=function(e){return e.ownerDocument||e},ye=function(e){return we(e).createDocumentFragment()},Ne=function(e,t){return we(e).createTextNode(t)},xe="append"in ye(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"}function u(e,t,n,r){return{name:r,node:t,path:n,type:e}}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=o;ca;)--c;l=u+r-c;var g=Array(l),b=s[c];for(--n;b;){for(var y=b,w=y.newi,N=y.oldi;n>w;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=i;)g[--l]=-1,--a;return g},P=function(e,t,n,r,o,i,a){var u,c,l,s,f,h,d,p=n+i,v=[];e:for(u=0;u<=p;u++){if(u>50)return null;for(d=u-1,f=u?v[u-1]:[0,0],h=v[u]=[],c=-u;c<=u;c+=2){for(s=c===-u||c!==u&&f[d+c-1]=0;u--){for(;s>0&&l>0&&a(r[o+s-1],e[t+l-1]);)m[g--]=0,s--,l--;if(!u)break;d=u-1,f=u?v[u-1]:[0,0],c=s-l,c===-u||c!==u&&f[d+c-1]>>0;n",t(r,i.firstChild.childNodes),r}var o="fragment",i="content"in n("template"),a=i?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(o),i=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;i.innerHTML=""+e+"
",a=i.querySelectorAll(u)}else i.innerHTML=e,a=i.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),U=function(e,t,n,r,o){var i="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(i?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],o=r.length,i=0;t&&i

',e.content.childNodes[0].getAttribute("tabindex")==Y)})(e.createElement("template"))||(Y="_dt: "+Y.slice(1,-1)+";");var ee="\x3c!--"+Y+"--\x3e",te=8,ne=1,re=3,oe=/^(?:style|textarea)$/i,ie=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ae=" \\f\\n\\r\\t",ue="[ "+ae+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ce="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",le="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",se=new RegExp(ce+ue+le+"+)([ "+ae+"]*/?>)","g"),fe=new RegExp(ce+ue+le+"*)([ "+ae+"]*/>)","g"),he=new RegExp("("+ue+"\\s*=\\s*)(['\"]?)"+ee+"\\2","gi"),de=new N,pe=new N,ve=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function n(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),o(n,!0)}function r(t){var n,r=[];for(n in t)r.push(n.replace(a,e),":",t[n],";");return r.join("")}function o(e,n){var o,a;return function(u){var c,l,s,f;switch(t(u)){case"object":if(u){if("object"===o){if(!n&&a!==u)for(l in a)l in u||(e[l]="")}else n?e.value="":e.cssText="";c=n?{}:e;for(l in u)f=u[l],s="number"!=typeof f||i.test(l)?f:f+"px",!n&&/^--/.test(l)?c.setProperty(l,s):c[l]=s;o="object",n?e.value=r(a=c):a=u;break}default:a!=u&&(o="string",a=u,n?e.value=u||"":e.cssText=u||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,a=/([^A-Z])([A-Z]+)/g;return function(e,t){return"ownerSVGElement"in e?n(e,t):o(e.style,!1)}}(),me="ownerSVGElement",ge=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var o={};return(n=function(e){var t="raw"+e.join("raw");return o[t]||(o[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),be=function(e){return e.ownerDocument||e},ye=function(e){return be(e).createDocumentFragment()},we=function(e,t){return be(e).createTextNode(t)},Ne="append"in ye(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r= length) { var m = moreStart; var l = lessStart; + while (m < moreEnd && l < lessEnd && compare(moreNodes[m], lessNodes[l])) { m++; l++; } + if (l === lessEnd) return moreStart; moreStart = m + 1; } + return -1; }; - var isReversed = function isReversed(futureNodes, futureEnd, currentNodes, currentStart, currentEnd, compare) { while (currentStart < currentEnd && compare(currentNodes[currentStart], futureNodes[futureEnd - 1])) { currentStart++; futureEnd--; - } return futureEnd === 0; + } + return futureEnd === 0; }; - var next = function next(get, list, i, length, before) { return i < length ? get(list[i], 0) : 0 < i ? get(list[i - 1], -0).nextSibling : before; }; - var remove = function remove(get, parent, children, start, end) { if (end - start < 2) parent.removeChild(get(children[start], -1));else { var range = parent.ownerDocument.createRange(); @@ -153,9 +193,7 @@ var hyperHTML = (function (document) { range.setEndAfter(get(children[end - 1], -1)); range.deleteContents(); } - }; - - // - - - - - - - - - - - - - - - - - - - + }; // - - - - - - - - - - - - - - - - - - - // diff related constants and utilities // - - - - - - - - - - - - - - - - - - - @@ -165,9 +203,9 @@ var hyperHTML = (function (document) { var SKIP_OND = 50; var HS = function HS(futureNodes, futureStart, futureEnd, futureChanges, currentNodes, currentStart, currentEnd, currentChanges) { - var k = 0; /* istanbul ignore next */ + var minLen = futureChanges < currentChanges ? futureChanges : currentChanges; var link = Array(minLen++); var tresh = Array(minLen); @@ -175,14 +213,21 @@ var hyperHTML = (function (document) { for (var i = 1; i < minLen; i++) { tresh[i] = currentEnd; - }var keymap = new Map$1(); + } + + var keymap = new Map$1(); + for (var _i = currentStart; _i < currentEnd; _i++) { keymap.set(currentNodes[_i], _i); - }for (var _i2 = futureStart; _i2 < futureEnd; _i2++) { + } + + for (var _i2 = futureStart; _i2 < futureEnd; _i2++) { var idxInOld = keymap.get(futureNodes[_i2]); + if (idxInOld != null) { k = findK(tresh, minLen, idxInOld); /* istanbul ignore else */ + if (-1 < k) { tresh[k] = idxInOld; link[k] = { @@ -196,12 +241,16 @@ var hyperHTML = (function (document) { k = --minLen; --currentEnd; + while (tresh[k] > currentEnd) { --k; - }minLen = currentChanges + futureChanges - k; + } + + minLen = currentChanges + futureChanges - k; var diff = Array(minLen); var ptr = link[k]; --futureEnd; + while (ptr) { var _ptr = ptr, newi = _ptr.newi, @@ -211,65 +260,72 @@ var hyperHTML = (function (document) { diff[--minLen] = INSERTION; --futureEnd; } + while (currentEnd > oldi) { diff[--minLen] = DELETION; --currentEnd; } + diff[--minLen] = SKIP; --futureEnd; --currentEnd; ptr = ptr.prev; } + while (futureEnd >= futureStart) { diff[--minLen] = INSERTION; --futureEnd; } + while (currentEnd >= currentStart) { diff[--minLen] = DELETION; --currentEnd; } - return diff; - }; - // this is pretty much the same petit-dom code without the delete map part + return diff; + }; // this is pretty much the same petit-dom code without the delete map part // https://github.com/yelouafi/petit-dom/blob/bd6f5c919b5ae5297be01612c524c40be45f14a7/src/vdom.js#L556-L561 + + var OND = function OND(futureNodes, futureStart, rows, currentNodes, currentStart, cols, compare) { var length = rows + cols; var v = []; - var d = void 0, - k = void 0, - r = void 0, - c = void 0, - pv = void 0, - cv = void 0, - pd = void 0; + var d, k, r, c, pv, cv, pd; + outer: for (d = 0; d <= length; d++) { /* istanbul ignore if */ if (d > SKIP_OND) return null; pd = d - 1; /* istanbul ignore next */ + pv = d ? v[d - 1] : [0, 0]; cv = v[d] = []; + for (k = -d; k <= d; k += 2) { if (k === -d || k !== d && pv[pd + k - 1] < pv[pd + k + 1]) { c = pv[pd + k + 1]; } else { c = pv[pd + k - 1] + 1; } + r = c - k; + while (c < cols && r < rows && compare(currentNodes[currentStart + c], futureNodes[futureStart + r])) { c++; r++; } + if (c === cols && r === rows) { break outer; } + cv[d + k] = c; } } var diff = Array(d / 2 + length / 2); var diffIdx = diff.length - 1; + for (d = v.length - 1; d >= 0; d--) { while (c > 0 && r > 0 && compare(currentNodes[currentStart + c - 1], futureNodes[futureStart + r - 1])) { // diagonal edge = equality @@ -277,11 +333,14 @@ var hyperHTML = (function (document) { c--; r--; } + if (!d) break; pd = d - 1; /* istanbul ignore next */ + pv = d ? v[d - 1] : [0, 0]; k = c - r; + if (k === -d || k !== d && pv[pd + k - 1] < pv[pd + k + 1]) { // vertical edge = insertion r--; @@ -292,6 +351,7 @@ var hyperHTML = (function (document) { diff[diffIdx--] = DELETION; } } + return diff; }; @@ -300,28 +360,34 @@ var hyperHTML = (function (document) { var length = diff.length; var currentIndex = currentStart; var i = 0; + while (i < length) { switch (diff[i++]) { case SKIP: futureStart++; currentIndex++; break; + case INSERTION: // TODO: bulk appends for sequential nodes live.set(futureNodes[futureStart], 1); append(get, parentNode, futureNodes, futureStart++, futureStart, currentIndex < currentLength ? get(currentNodes[currentIndex], 1) : before); break; + case DELETION: currentIndex++; break; } } + i = 0; + while (i < length) { switch (diff[i++]) { case SKIP: currentStart++; break; + case DELETION: // TODO: bulk removes for sequential nodes if (live.has(currentNodes[currentStart])) currentStart++;else remove(get, parentNode, currentNodes, currentStart++, currentStart); @@ -333,10 +399,12 @@ var hyperHTML = (function (document) { var findK = function findK(ktr, length, j) { var lo = 1; var hi = length; + while (lo < hi) { var mid = (lo + hi) / 2 >>> 0; if (j < ktr[mid]) hi = mid;else lo = mid + 1; } + return lo; }; @@ -355,43 +423,37 @@ var hyperHTML = (function (document) { // node(generic) => Node ) { if (!options) options = {}; - var compare = options.compare || eqeq; var get = options.node || identity; var before = options.before == null ? null : get(options.before, 0); - var currentLength = currentNodes.length; var currentEnd = currentLength; var currentStart = 0; - var futureEnd = futureNodes.length; - var futureStart = 0; + var futureStart = 0; // common prefix - // common prefix while (currentStart < currentEnd && futureStart < futureEnd && compare(currentNodes[currentStart], futureNodes[futureStart])) { currentStart++; futureStart++; - } + } // common suffix + - // common suffix while (currentStart < currentEnd && futureStart < futureEnd && compare(currentNodes[currentEnd - 1], futureNodes[futureEnd - 1])) { currentEnd--; futureEnd--; } var currentSame = currentStart === currentEnd; - var futureSame = futureStart === futureEnd; + var futureSame = futureStart === futureEnd; // same list - // same list - if (currentSame && futureSame) return futureNodes; + if (currentSame && futureSame) return futureNodes; // only stuff to add - // only stuff to add if (currentSame && futureStart < futureEnd) { append(get, parentNode, futureNodes, futureStart, futureEnd, next(get, currentNodes, currentStart, currentLength, before)); return futureNodes; - } + } // only stuff to remove + - // only stuff to remove if (futureSame && currentStart < currentEnd) { remove(get, parentNode, currentNodes, currentStart, currentEnd); return futureNodes; @@ -399,12 +461,11 @@ var hyperHTML = (function (document) { var currentChanges = currentEnd - currentStart; var futureChanges = futureEnd - futureStart; - var i = -1; + var i = -1; // 2 simple indels: the shortest sequence is a subsequence of the longest - // 2 simple indels: the shortest sequence is a subsequence of the longest if (currentChanges < futureChanges) { - i = indexOf(futureNodes, futureStart, futureEnd, currentNodes, currentStart, currentEnd, compare); - // inner diff + i = indexOf(futureNodes, futureStart, futureEnd, currentNodes, currentStart, currentEnd, compare); // inner diff + if (-1 < i) { append(get, parentNode, futureNodes, futureStart, i, get(currentNodes[currentStart], 0)); append(get, parentNode, futureNodes, i + currentChanges, futureEnd, next(get, currentNodes, currentEnd, currentLength, before)); @@ -413,48 +474,64 @@ var hyperHTML = (function (document) { } /* istanbul ignore else */ else if (futureChanges < currentChanges) { - i = indexOf(currentNodes, currentStart, currentEnd, futureNodes, futureStart, futureEnd, compare); - // outer diff + i = indexOf(currentNodes, currentStart, currentEnd, futureNodes, futureStart, futureEnd, compare); // outer diff + if (-1 < i) { remove(get, parentNode, currentNodes, currentStart, i); remove(get, parentNode, currentNodes, i + futureChanges, currentEnd); return futureNodes; } - } - - // common case with one replacement for many nodes + } // common case with one replacement for many nodes // or many nodes replaced for a single one + /* istanbul ignore else */ + + if (currentChanges < 2 || futureChanges < 2) { append(get, parentNode, futureNodes, futureStart, futureEnd, get(currentNodes[currentStart], 0)); remove(get, parentNode, currentNodes, currentStart, currentEnd); return futureNodes; - } - - // the half match diff part has been skipped in petit-dom + } // the half match diff part has been skipped in petit-dom // https://github.com/yelouafi/petit-dom/blob/bd6f5c919b5ae5297be01612c524c40be45f14a7/src/vdom.js#L391-L397 // accordingly, I think it's safe to skip in here too // if one day it'll come out like the speediest thing ever to do // then I might add it in here too - // Extra: before going too fancy, what about reversed lists ? // This should bail out pretty quickly if that's not the case. + + if (currentChanges === futureChanges && isReversed(futureNodes, futureEnd, currentNodes, currentStart, currentEnd, compare)) { append(get, parentNode, futureNodes, futureStart, futureEnd, next(get, currentNodes, currentEnd, currentLength, before)); return futureNodes; - } + } // last resort through a smart diff - // last resort through a smart diff - smartDiff(get, parentNode, futureNodes, futureStart, futureEnd, futureChanges, currentNodes, currentStart, currentEnd, currentChanges, currentLength, compare, before); + smartDiff(get, parentNode, futureNodes, futureStart, futureEnd, futureChanges, currentNodes, currentStart, currentEnd, currentChanges, currentLength, compare, before); return futureNodes; }; + function _typeof(obj) { + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } + /*! (c) Andrea Giammarchi - ISC */ - var self$3 = null || /* istanbul ignore next */{}; + var self$3 = null || + /* istanbul ignore next */ + {}; self$3.CustomEvent = typeof CustomEvent === 'function' ? CustomEvent : function (__p__) { CustomEvent[__p__] = new CustomEvent('').constructor[__p__]; return CustomEvent; + function CustomEvent(type, init) { if (!init) init = {}; var e = document.createEvent('CustomEvent'); @@ -464,7 +541,6 @@ var hyperHTML = (function (document) { }('prototype'); var CustomEvent$1 = self$3.CustomEvent; - // hyperHTML.Component is a very basic class // able to create Custom Elements like components // including the ability to listen to connect/disconnect // events via onconnect/ondisconnect attributes @@ -472,44 +548,54 @@ var hyperHTML = (function (document) { // The main difference is that declared components // will not automatically render on setState(...) // to simplify state handling on render. + function Component() { return this; // this is needed in Edge !!! - } - - // Component is lazily setup because it needs + } // Component is lazily setup because it needs // wire mechanism as lazy content + function setup(content) { // there are various weakly referenced variables in here // and mostly are to use Component.for(...) static method. var children = new WeakMap$1(); var create = Object.create; + var createEntry = function createEntry(wm, id, component) { wm.set(id, component); return component; }; + var get = function get(Class, info, context, id) { var relation = info.get(Class) || relate(Class, info); - switch (typeof id) { + + switch (_typeof(id)) { case 'object': case 'function': var wm = relation.w || (relation.w = new WeakMap$1()); return wm.get(id) || createEntry(wm, id, new Class(context)); + default: var sm = relation.p || (relation.p = create(null)); return sm[id] || (sm[id] = new Class(context)); } }; + var relate = function relate(Class, info) { - var relation = { w: null, p: null }; + var relation = { + w: null, + p: null + }; info.set(Class, relation); return relation; }; + var set = function set(context) { var info = new Map$1(); children.set(context, info); return info; - }; - // The Component Class + }; // The Component Class + + Object.defineProperties(Component, { // Component.for(context[, id]) is a convenient way // to automatically relate data/context to children components @@ -563,6 +649,7 @@ var hyperHTML = (function (document) { event.component = this; return (_wire$.dispatchEvent ? _wire$ : _wire$.childNodes[0]).dispatchEvent(event); } + return false; } }, @@ -573,19 +660,21 @@ var hyperHTML = (function (document) { value: function value(state, render) { var target = this.state; var source = typeof state === 'function' ? state.call(this, target) : state; + for (var key in source) { target[key] = source[key]; - }if (render !== false) this.render(); + } + + if (render !== false) this.render(); return this; } } }); - } - - // instead of a secret key I could've used a WeakMap + } // instead of a secret key I could've used a WeakMap // However, attaching a property directly will result // into better performance with thousands of components // hanging around, and less memory pressure caused by the WeakMap + var lazyGetter = function lazyGetter(type, fn) { var secret = '_' + type + '$'; return { @@ -596,9 +685,9 @@ var hyperHTML = (function (document) { setValue(this, secret, value); } }; - }; + }; // shortcut to set value on get or set(value) + - // shortcut to set value on get or set(value) var setValue = function setValue(self, secret, value) { return Object.defineProperty(self, secret, { configurable: true, @@ -612,14 +701,10 @@ var hyperHTML = (function (document) { var intents = {}; var keys = []; var hasOwnProperty = intents.hasOwnProperty; - var length = 0; - var Intent = { - // used to invoke right away hyper:attributes attributes: attributes, - // hyperHTML.define('intent', (object, update) => {...}) // can be used to define a third parts update mechanism // when every other known mechanism failed. @@ -630,17 +715,18 @@ var hyperHTML = (function (document) { if (!(intent in intents)) { length = keys.push(intent); } + intents[intent] = callback; } else { attributes[intent] = callback; } }, - // this method is used internally as last resort // to retrieve a value out of an object invoke: function invoke(object, callback) { for (var i = 0; i < length; i++) { var key = keys[i]; + if (hasOwnProperty.call(object, key)) { return intents[key](object[key], callback); } @@ -661,7 +747,6 @@ var hyperHTML = (function (document) { var FRAGMENT = 'fragment'; var TEMPLATE = 'template'; var HAS_CONTENT = 'content' in create(TEMPLATE); - var createHTML = HAS_CONTENT ? function (html) { var template = create(TEMPLATE); template.innerHTML = html; @@ -670,6 +755,7 @@ var hyperHTML = (function (document) { var content = create(FRAGMENT); var template = create(TEMPLATE); var childNodes = null; + if (/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(html)) { var selector = RegExp.$1; template.innerHTML = '' + html + '
'; @@ -678,28 +764,29 @@ var hyperHTML = (function (document) { template.innerHTML = html; childNodes = template.childNodes; } + append(content, childNodes); return content; }; - return function createContent(markup, type) { return (type === 'svg' ? createSVG : createHTML)(markup); }; function append(root, childNodes) { var length = childNodes.length; + while (length--) { root.appendChild(childNodes[0]); } } function create(element) { - return element === FRAGMENT ? document.createDocumentFragment() : document.createElement(element); - } - - // it could use createElementNS when hasNode is there + return element === FRAGMENT ? document.createDocumentFragment() : document.createElementNS('http://www.w3.org/1999/xhtml', element); + } // it could use createElementNS when hasNode is there // but this fallback is equally fast and easier to maintain // it is also battle tested already in all IE + + function createSVG(svg) { var content = create(FRAGMENT); var template = create('div'); @@ -723,16 +810,23 @@ var hyperHTML = (function (document) { notObserving = !notObserving; startObserving(node.ownerDocument); } + observer.add(node); return node; }; + function startObserving(document) { var dispatched = null; + try { - new MutationObserver(changes).observe(document, { subtree: true, childList: true }); + new MutationObserver(changes).observe(document, { + subtree: true, + childList: true + }); } catch (o_O) { var timer = 0; var records = []; + var reschedule = function reschedule(record) { records.push(record); clearTimeout(timer); @@ -740,25 +834,38 @@ var hyperHTML = (function (document) { changes(records.splice(timer = 0, records.length)); }, 0); }; + document.addEventListener('DOMNodeRemoved', function (event) { - reschedule({ addedNodes: [], removedNodes: [event.target] }); + reschedule({ + addedNodes: [], + removedNodes: [event.target] + }); }, true); document.addEventListener('DOMNodeInserted', function (event) { - reschedule({ addedNodes: [event.target], removedNodes: [] }); + reschedule({ + addedNodes: [event.target], + removedNodes: [] + }); }, true); } + function changes(records) { dispatched = new Tracker(); + for (var record, length = records.length, i = 0; i < length; i++) { record = records[i]; dispatchAll(record.removedNodes, DISCONNECTED, CONNECTED); dispatchAll(record.addedNodes, CONNECTED, DISCONNECTED); } + dispatched = null; } + function dispatchAll(nodes, type, counter) { - for (var node, event = new Event(type), length = nodes.length, i = 0; i < length; (node = nodes[i++]).nodeType === 1 && dispatchTarget(node, event, type, counter)) {} + for (var node, event = new Event(type), length = nodes.length, i = 0; i < length; (node = nodes[i++]).nodeType === 1 && dispatchTarget(node, event, type, counter)) { + } } + function dispatchTarget(node, event, type, counter) { if (observer.has(node) && !dispatched[type].has(node)) { dispatched[counter].delete(node); @@ -778,11 +885,13 @@ var hyperHTML = (function (document) { } */ } - for (var - // apparently is node.children || IE11 ... ^_^;; + + for (var // apparently is node.children || IE11 ... ^_^;; // https://github.com/WebReflection/disconnected/issues/1 - children = node.children || [], length = children.length, i = 0; i < length; dispatchTarget(children[i++], event, type, counter)) {} + children = node.children || [], length = children.length, i = 0; i < length; dispatchTarget(children[i++], event, type, counter)) { + } } + function Tracker() { this[CONNECTED] = new WeakSet(); this[DISCONNECTED] = new WeakSet(); @@ -791,73 +900,23 @@ var hyperHTML = (function (document) { } /*! (c) Andrea Giammarchi - ISC */ - var createContent$1 = function (document) { - - var FRAGMENT = 'fragment'; - var TEMPLATE = 'template'; - var HAS_CONTENT = 'content' in create(TEMPLATE); - - var createHTML = HAS_CONTENT ? function (html) { - var template = create(TEMPLATE); - template.innerHTML = html; - return template.content; - } : function (html) { - var content = create(FRAGMENT); - var template = create(TEMPLATE); - var childNodes = null; - if (/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(html)) { - var selector = RegExp.$1; - template.innerHTML = '' + html + '
'; - childNodes = template.querySelectorAll(selector); - } else { - template.innerHTML = html; - childNodes = template.childNodes; - } - append(content, childNodes); - return content; - }; - - return function createContent(markup, type) { - return (type === 'svg' ? createSVG : createHTML)(markup); - }; - - function append(root, childNodes) { - var length = childNodes.length; - while (length--) { - root.appendChild(childNodes[0]); - } - } - - function create(element) { - return element === FRAGMENT ? document.createDocumentFragment() : document.createElementNS('http://www.w3.org/1999/xhtml', element); - } - - // it could use createElementNS when hasNode is there - // but this fallback is equally fast and easier to maintain - // it is also battle tested already in all IE - function createSVG(svg) { - var content = create(FRAGMENT); - var template = create('div'); - template.innerHTML = '' + svg + ''; - append(content, template.firstChild.childNodes); - return content; - } - }(document); /*! (c) Andrea Giammarchi - ISC */ var importNode = function (document, appendChild, cloneNode, createTextNode, importNode) { - var native = importNode in document; - // IE 11 has problems with cloning templates: + var native = importNode in document; // IE 11 has problems with cloning templates: // it "forgets" empty childNodes. This feature-detects that. + var fragment = document.createDocumentFragment(); fragment[appendChild](document[createTextNode]('g')); fragment[appendChild](document[createTextNode]('')); var content = native ? document[importNode](fragment, true) : fragment[cloneNode](true); return content.childNodes.length < 2 ? function importNode(node, deep) { var clone = node[cloneNode](); + for (var childNodes = node.childNodes || [], length = childNodes.length, i = 0; deep && i < length; i++) { clone[appendChild](importNode(childNodes[i], deep)); } + return clone; } : native ? document[importNode] : function (node, deep) { return node[cloneNode](!!deep); @@ -869,33 +928,30 @@ var hyperHTML = (function (document) { }; // Custom - var UID = '-' + Math.random().toFixed(6) + '%'; - // Edge issue! + var UID = '-' + Math.random().toFixed(6) + '%'; // Edge issue! + if (!function (template, content, tabindex) { return content in template && (template.innerHTML = '

', template[content].childNodes[0].getAttribute(tabindex) == UID); }(document.createElement('template'), 'content', 'tabindex')) { UID = '_dt: ' + UID.slice(1, -1) + ';'; } - var UIDC = ''; - // DOM + var UIDC = ''; // DOM + var COMMENT_NODE = 8; var ELEMENT_NODE = 1; var TEXT_NODE = 3; - var SHOULD_USE_TEXT_CONTENT = /^(?:style|textarea)$/i; var VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i; function sanitize (template) { return template.join(UIDC).replace(selfClosing, fullClosing).replace(attrSeeker, attrReplacer); } - var spaces = ' \\f\\n\\r\\t'; var almostEverything = '[^ ' + spaces + '\\/>"\'=]+'; var attrName = '[ ' + spaces + ']+' + almostEverything; var tagName = '<([A-Za-z]+[A-Za-z0-9:_-]*)((?:'; var attrPartials = '(?:\\s*=\\s*(?:\'[^\']*?\'|"[^"]*?"|<[^>]*?>|' + almostEverything + '))?)'; - var attrSeeker = new RegExp(tagName + attrName + attrPartials + '+)([ ' + spaces + ']*/?>)', 'g'); var selfClosing = new RegExp(tagName + attrName + attrPartials + '*)([ ' + spaces + ']*/>)', 'g'); var findAttributes = new RegExp('(' + attrName + '\\s*=\\s*)([\'"]?)' + UIDC + '\\2', 'gi'); @@ -913,51 +969,66 @@ var hyperHTML = (function (document) { } function create(type, node, path, name) { - return { name: name, node: node, path: path, type: type }; + return { + name: name, + node: node, + path: path, + type: type + }; } function find(node, path) { var length = path.length; var i = 0; + while (i < length) { node = node.childNodes[path[i++]]; - }return node; + } + + return node; } function parse(node, holes, parts, path) { var childNodes = node.childNodes; var length = childNodes.length; var i = 0; + while (i < length) { var child = childNodes[i]; + switch (child.nodeType) { case ELEMENT_NODE: var childPath = path.concat(i); parseAttributes(child, holes, parts, childPath); parse(child, holes, parts, childPath); break; + case COMMENT_NODE: if (child.textContent === UID) { parts.shift(); - holes.push( - // basicHTML or other non standard engines + holes.push( // basicHTML or other non standard engines // might end up having comments in nodes // where they shouldn't, hence this check. SHOULD_USE_TEXT_CONTENT.test(node.nodeName) ? create('text', node, path) : create('any', child, path.concat(i))); } + break; + case TEXT_NODE: // the following ignore is actually covered by browsers // only basicHTML ends up on previous COMMENT_NODE case // instead of TEXT_NODE because it knows nothing about // special style or textarea behavior + /* istanbul ignore if */ if (SHOULD_USE_TEXT_CONTENT.test(node.nodeName) && trim.call(child.textContent) === UIDC) { parts.shift(); holes.push(create('text', node, path)); } + break; } + i++; } } @@ -969,43 +1040,49 @@ var hyperHTML = (function (document) { var array = remove.slice.call(attributes, 0); var length = array.length; var i = 0; + while (i < length) { var attribute = array[i++]; + if (attribute.value === UID) { - var name = attribute.name; - // the following ignore is covered by IE + var name = attribute.name; // the following ignore is covered by IE // and the IE9 double viewBox test + /* istanbul ignore else */ + if (!cache.has(name)) { var realName = parts.shift().replace(/^(?:|[\S\s]*?\s)(\S+?)\s*=\s*['"]?$/, '$1'); - var value = attributes[realName] || - // the following ignore is covered by browsers + var value = attributes[realName] || // the following ignore is covered by browsers // while basicHTML is already case-sensitive + /* istanbul ignore next */ attributes[realName.toLowerCase()]; cache.set(name, value); holes.push(create('attr', value, path, realName)); } + remove.push(attribute); } } + length = remove.length; i = 0; + while (i < length) { // Edge HTML bug #16878726 var attr = remove[i++]; - if (/^id$/i.test(attr.name)) node.removeAttribute(attr.name); - // standard browsers would work just fine here + if (/^id$/i.test(attr.name)) node.removeAttribute(attr.name); // standard browsers would work just fine here else node.removeAttributeNode(attr); - } - - // This is a very specific Firefox/Safari issue + } // This is a very specific Firefox/Safari issue // but since it should be a not so common pattern, // it's probably worth patching regardless. // Basically, scripts created through strings are death. // You need to create fresh new scripts instead. // TODO: is there any other node that needs such nonsense? + + var nodeName = node.nodeName; + if (/^script$/i.test(nodeName)) { // this used to be like that // var script = createElement(node, nodeName); @@ -1015,15 +1092,17 @@ var hyperHTML = (function (document) { var script = document.createElement(nodeName); length = attributes.length; i = 0; + while (i < length) { script.setAttributeNode(attributes[i++].cloneNode(true)); - }script.textContent = node.textContent; + } + + script.textContent = node.textContent; node.parentNode.replaceChild(script, node); } } // globals - var parsed = new WeakMap$1(); var referenced = new WeakMap$1(); @@ -1031,7 +1110,7 @@ var hyperHTML = (function (document) { var markup = sanitize(template); var transform = options.transform; if (transform) markup = transform(markup); - var content = createContent$1(markup, options.type); + var content = createContent(markup, options.type); cleanContent(content); var holes = []; parse(content, holes, template.slice(0), []); @@ -1041,32 +1120,41 @@ var hyperHTML = (function (document) { var callbacks = []; var len = holes.length; var i = 0; + while (i < len) { var info = holes[i++]; var node = find(content, info.path); + switch (info.type) { case 'any': callbacks.push(options.any(node, [])); break; + case 'attr': callbacks.push(options.attribute(node, info.name, info.node)); break; + case 'text': callbacks.push(options.text(node)); node.textContent = ''; break; } } + return function () { var length = arguments.length; var values = length - 1; var i = 1; + if (len !== values) { throw new Error(values + ' values instead of ' + len + '\n' + template.join(', ')); } + while (i < length) { callbacks[i - 1](arguments[i++]); - }return content; + } + + return content; }; } }; @@ -1098,8 +1186,10 @@ var hyperHTML = (function (document) { function cleanContent(fragment) { var childNodes = fragment.childNodes; var i = childNodes.length; + while (i--) { var child = childNodes[i]; + if (child.nodeType !== 1 && trim.call(child.textContent).length === 0) { fragment.removeChild(child); } @@ -1108,16 +1198,17 @@ var hyperHTML = (function (document) { /*! (c) Andrea Giammarchi - ISC */ var hyperStyle = function () { - // from https://github.com/developit/preact/blob/33fc697ac11762a1cb6e71e9847670d047af7ce5/src/varants.js var IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i; var hyphen = /([^A-Z])([A-Z]+)/g; return function hyperStyle(node, original) { return 'ownerSVGElement' in node ? svg(node, original) : update(node.style, false); }; + function ized($0, $1, $2) { return $1 + '-' + $2.toLowerCase(); } + function svg(node, original) { var style; if (original) style = original.cloneNode(true);else { @@ -1128,18 +1219,24 @@ var hyperHTML = (function (document) { node.setAttributeNode(style); return update(style, true); } + function toStyle(object) { var key, css = []; + for (key in object) { css.push(key.replace(hyphen, ized), ':', object[key], ';'); - }return css.join(''); + } + + return css.join(''); } + function update(style, isSVG) { var oldType, oldValue; return function (newValue) { var info, key, styleValue, value; - switch (typeof newValue) { + + switch (_typeof(newValue)) { case 'object': if (newValue) { if (oldType === 'object') { @@ -1155,35 +1252,38 @@ var hyperHTML = (function (document) { } else { if (isSVG) style.value = '';else style.cssText = ''; } + info = isSVG ? {} : style; + for (key in newValue) { value = newValue[key]; styleValue = typeof value === 'number' && !IS_NON_DIMENSIONAL.test(key) ? value + 'px' : value; if (!isSVG && /^--/.test(key)) info.setProperty(key, styleValue);else info[key] = styleValue; } + oldType = 'object'; if (isSVG) style.value = toStyle(oldValue = info);else oldValue = newValue; break; } + default: if (oldValue != newValue) { oldType = 'string'; oldValue = newValue; if (isSVG) style.value = newValue || '';else style.cssText = newValue || ''; } + break; } }; } }(); - var G = document.defaultView; - var DOCUMENT_FRAGMENT_NODE$1 = 11; + // Node.CONSTANTS + var DOCUMENT_FRAGMENT_NODE$1 = 11; // SVG related constants - // SVG related constants - var OWNER_SVG_ELEMENT = 'ownerSVGElement'; + var OWNER_SVG_ELEMENT = 'ownerSVGElement'; // Custom Elements / MutationObserver constants - // Custom Elements / MutationObserver constants var CONNECTED = 'connected'; var DISCONNECTED = 'dis' + CONNECTED; @@ -1191,33 +1291,32 @@ var hyperHTML = (function (document) { var RAW = 'raw'; var isNoOp = false; + var _templateLiteral = function templateLiteral(tl) { - if ( - // for badly transpiled literals - !(RAW in tl) || - // for some version of TypeScript - tl.propertyIsEnumerable(RAW) || - // and some other version of TypeScript - !Object.isFrozen(tl.raw) || - // or for Firefox < 55 + if ( // for badly transpiled literals + !(RAW in tl) || // for some version of TypeScript + tl.propertyIsEnumerable(RAW) || // and some other version of TypeScript + !Object.isFrozen(tl.raw) || // or for Firefox < 55 /Firefox\/(\d+)/.test((document.defaultView.navigator || {}).userAgent) && parseFloat(RegExp.$1) < 55) { var forever = {}; + _templateLiteral = function templateLiteral(tl) { var key = RAW + tl.join(RAW); return forever[key] || (forever[key] = tl); }; + return _templateLiteral(tl); } else { isNoOp = true; return tl; } }; + return function (tl) { return isNoOp ? tl : _templateLiteral(tl); }; }(); - // these are tiny helpers to simplify most common operations needed here var doc = function doc(node) { return node.ownerDocument || node; }; @@ -1226,32 +1325,33 @@ var hyperHTML = (function (document) { }; var text = function text(node, _text) { return doc(node).createTextNode(_text); - }; - - // appends an array of nodes + }; // appends an array of nodes // to a generic node/fragment // When available, uses append passing all arguments at once // hoping that's somehow faster, even if append has more checks on type // istanbul ignore next + var append$1 = 'append' in fragment(document) ? function (node, childNodes) { node.append.apply(node, childNodes); } : function (node, childNodes) { var length = childNodes.length; + for (var i = 0; i < length; i++) { node.appendChild(childNodes[i]); } - }; + }; // normalizes the template once for all arguments cases - // normalizes the template once for all arguments cases var reArguments = function reArguments(template) { var args = [templateLiteral(template)]; + for (var i = 1, length = arguments.length; i < length; i++) { args[i] = arguments[i]; - }return args; - }; + } - // just recycling a one-off array to use slice + return args; + }; // just recycling a one-off array to use slice // in every needed place + var slice = [].slice; function Wire(childNodes) { @@ -1260,22 +1360,23 @@ var hyperHTML = (function (document) { this.first = childNodes[0]; this.last = childNodes[this.length - 1]; this._ = null; - } + } // when a wire is inserted, all its nodes will follow - // when a wire is inserted, all its nodes will follow Wire.prototype.valueOf = function valueOf(different) { var noFragment = this._ == null; if (noFragment) this._ = fragment(this.first); /* istanbul ignore else */ + if (noFragment || different) append$1(this._, this.childNodes); return this._; - }; + }; // when a wire is removed, all its nodes must be removed as well + - // when a wire is removed, all its nodes must be removed as well Wire.prototype.remove = function remove() { this._ = null; var first = this.first; var last = this.last; + if (this.length === 2) { last.parentNode.removeChild(last); } else { @@ -1284,37 +1385,43 @@ var hyperHTML = (function (document) { range.setEndAfter(last); range.deleteContents(); } + return first; }; - var observe = disconnected({ Event: CustomEvent$1, WeakSet: WeakSet$1 }); + var observe = disconnected({ + Event: CustomEvent$1, + WeakSet: WeakSet$1 + }); - // returns an intent to explicitly inject content as html var asHTML = function asHTML(html) { - return { html: html }; - }; + return { + html: html + }; + }; // returns nodes from wires and components + - // returns nodes from wires and components var asNode = function asNode(item, i) { - return 'ELEMENT_NODE' in item ? item : item.constructor === Wire ? - // in the Wire case, the content can be + return 'ELEMENT_NODE' in item ? item : item.constructor === Wire ? // in the Wire case, the content can be // removed, post-pended, inserted, or pre-pended and // all these cases are handled by domdiff already + /* istanbul ignore next */ 1 / i < 0 ? i ? item.remove() : item.last : i ? item.valueOf(true) : item.first : asNode(item.render(), i); - }; + }; // returns true if domdiff can handle the value + - // returns true if domdiff can handle the value var canDiff = function canDiff(value) { return 'ELEMENT_NODE' in value || value instanceof Wire || value instanceof Component; - }; - - // when a Promise is used as interpolation value + }; // when a Promise is used as interpolation value // its result must be parsed once resolved. // This callback is in charge of understanding what to do // with a returned value once the promise is resolved. + + var invokeAtDistance = function invokeAtDistance(value, callback) { callback(value.placeholder); + if ('text' in value) { Promise.resolve(value.text).then(String).then(callback); } else if ('any' in value) { @@ -1324,14 +1431,14 @@ var hyperHTML = (function (document) { } else { Promise.resolve(Intent.invoke(value, callback)).then(callback); } - }; + }; // quick and dirty way to check for Promise/ish values + - // quick and dirty way to check for Promise/ish values var isPromise_ish = function isPromise_ish(value) { return value != null && 'then' in value; - }; + }; // list of attributes that should not be directly assigned + - // list of attributes that should not be directly assigned var readOnly = /^(?:form|list)$/i; function Tagger(type) { @@ -1340,7 +1447,6 @@ var hyperHTML = (function (document) { } Tagger.prototype = { - // there are four kind of attributes, and related behavior: // * events, with a name starting with `on`, to add/remove event listeners // * special, with a name present in their inherited prototype, accessed directly @@ -1350,19 +1456,20 @@ var hyperHTML = (function (document) { // fully inspired by Preact library and its simplicity. attribute: function attribute(node, name, original) { var isSVG = OWNER_SVG_ELEMENT in node; - var oldValue = void 0; - // if the attribute is the style one + var oldValue; // if the attribute is the style one // handle it differently from others - if (name === 'style') return hyperStyle(node, original, isSVG); - // the name is an event one, + + if (name === 'style') return hyperStyle(node, original, isSVG); // the name is an event one, // add/remove event listeners accordingly else if (/^on/.test(name)) { var type = name.slice(2); + if (type === CONNECTED || type === DISCONNECTED) { observe(node); } else if (name.toLowerCase() in node) { type = type.toLowerCase(); } + return function (newValue) { if (oldValue !== newValue) { if (oldValue) node.removeEventListener(type, oldValue, false); @@ -1370,16 +1477,17 @@ var hyperHTML = (function (document) { if (newValue) node.addEventListener(type, newValue, false); } }; - } - // the attribute is special ('value' in input) + } // the attribute is special ('value' in input) // and it's not SVG *or* the name is exactly data, // in this case assign the value directly else if (name === 'data' || !isSVG && name in node && !readOnly.test(name)) { return function (newValue) { if (oldValue !== newValue) { oldValue = newValue; + if (node[name] !== newValue) { node[name] = newValue; + if (newValue == null) { node.removeAttribute(name); } @@ -1391,8 +1499,7 @@ var hyperHTML = (function (document) { oldValue = Intent.attributes[name](node, any); node.setAttribute(name, oldValue == null ? '' : oldValue); }; - } - // in every other case, use the attribute node as it is + } // in every other case, use the attribute node as it is // update only the value, set it as node only when/if needed else { var owner = false; @@ -1400,15 +1507,18 @@ var hyperHTML = (function (document) { return function (newValue) { if (oldValue !== newValue) { oldValue = newValue; + if (attribute.value !== newValue) { if (newValue == null) { if (owner) { owner = false; node.removeAttributeNode(attribute); } + attribute.value = newValue; } else { attribute.value = newValue; + if (!owner) { owner = true; node.setAttributeNode(attribute); @@ -1419,8 +1529,6 @@ var hyperHTML = (function (document) { }; } }, - - // in a hyper(node)`
${content}
` case // everything could happen: // * it's a JS primitive, stored as text @@ -1431,12 +1539,18 @@ var hyperHTML = (function (document) { // * it's an Array, resolve all values if Promises and/or // update the node with the resulting list of content any: function any(node, childNodes) { - var diffOptions = { node: asNode, before: node }; - var nodeType = OWNER_SVG_ELEMENT in node ? /* istanbul ignore next */'svg' : 'html'; + var diffOptions = { + node: asNode, + before: node + }; + var nodeType = OWNER_SVG_ELEMENT in node ? + /* istanbul ignore next */ + 'svg' : 'html'; var fastPath = false; - var oldValue = void 0; + var oldValue; + var anyContent = function anyContent(value) { - switch (typeof value) { + switch (_typeof(value)) { case 'string': case 'number': case 'boolean': @@ -1450,10 +1564,13 @@ var hyperHTML = (function (document) { oldValue = value; childNodes = domdiff(node.parentNode, childNodes, [text(node, value)], diffOptions); } + break; + case 'function': anyContent(value(node)); break; + case 'object': case 'undefined': if (value == null) { @@ -1461,29 +1578,36 @@ var hyperHTML = (function (document) { childNodes = domdiff(node.parentNode, childNodes, [], diffOptions); break; } + default: fastPath = false; oldValue = value; + if (isArray(value)) { if (value.length === 0) { if (childNodes.length) { childNodes = domdiff(node.parentNode, childNodes, [], diffOptions); } } else { - switch (typeof value[0]) { + switch (_typeof(value[0])) { case 'string': case 'number': case 'boolean': - anyContent({ html: value }); + anyContent({ + html: value + }); break; + case 'object': if (isArray(value[0])) { value = value.concat.apply([], value); } + if (isPromise_ish(value[0])) { Promise.all(value).then(anyContent); break; } + default: childNodes = domdiff(node.parentNode, childNodes, value, diffOptions); break; @@ -1506,23 +1630,26 @@ var hyperHTML = (function (document) { } else { anyContent(Intent.invoke(value, anyContent)); } + break; } }; + return anyContent; }, - - // style or textareas don't accept HTML as content // it's pointless to transform or analyze anything // different from text there but it's worth checking // for possible defined intents. text: function text$$1(node) { - var oldValue = void 0; + var oldValue; + var textContent = function textContent(value) { if (oldValue !== value) { oldValue = value; - var type = typeof value; + + var type = _typeof(value); + if (type === 'object' && value) { if (isPromise_ish(value)) { value.then(textContent); @@ -1546,14 +1673,12 @@ var hyperHTML = (function (document) { } } }; + return textContent; } }; - // all wires used per each context - var wires = new WeakMap$1(); - - // A wire is a callback used as tag function + var wires = new WeakMap$1(); // A wire is a callback used as tag function // to lazily relate a generic object to a template literal. // hyper.wire(user)`
${user.name}
`; => the div#user // This provides the ability to have a unique DOM structure @@ -1562,22 +1687,22 @@ var hyperHTML = (function (document) { // via html:id or :id convention. Such :id allows same JS objects // to be associated to different DOM structures accordingly with // the used template literal without losing previously rendered parts. + var wire = function wire(obj, type) { return obj == null ? content(type || 'html') : weakly(obj, type || 'html'); - }; - - // A wire content is a virtual reference to one or more nodes. + }; // A wire content is a virtual reference to one or more nodes. // It's represented by either a DOM node, or an Array. // In both cases, the wire content role is to simply update // all nodes through the list of related callbacks. // In few words, a wire content is like an invisible parent node // in charge of updating its content like a bound element would do. + + var content = function content(type) { - var wire = void 0, - tagger = void 0, - template = void 0; + var wire, tagger, template; return function () { var args = reArguments.apply(null, arguments); + if (template !== args[0]) { template = args[0]; tagger = new Tagger(type); @@ -1585,26 +1710,27 @@ var hyperHTML = (function (document) { } else { tagger.apply(tagger, args); } + return wire; }; - }; - - // wires are weakly created through objects. + }; // wires are weakly created through objects. // Each object can have multiple wires associated // and this is thanks to the type + :id feature. + + var weakly = function weakly(obj, type) { var i = type.indexOf(':'); var wire = wires.get(obj); var id = type; + if (-1 < i) { id = type.slice(i + 1); type = type.slice(0, i) || 'html'; } + if (!wire) wires.set(obj, wire = {}); return wire[id] || (wire[id] = content(type)); - }; - - // A document fragment loses its nodes + }; // A document fragment loses its nodes // as soon as it is appended into another node. // This has the undesired effect of losing wired content // on a second render call, because (by then) the fragment would be empty: @@ -1616,55 +1742,60 @@ var hyperHTML = (function (document) { // wire content throughout multiple renderings. // The initial fragment, at this point, would be used as unique reference to this // array of nodes or to this single referenced node. + + var wireContent = function wireContent(node) { var childNodes = node.childNodes; return childNodes.length === 1 ? childNodes[0] : new Wire(slice.call(childNodes, 0)); }; - // a weak collection of contexts that // are already known to hyperHTML - var bewitched = new WeakMap$1(); - // better known as hyper.bind(node), the render is + var bewitched = new WeakMap$1(); // better known as hyper.bind(node), the render is // the main tag function in charge of fully upgrading // or simply updating, contexts used as hyperHTML targets. // The `this` context is either a regular DOM node or a fragment. + function render() { var wicked = bewitched.get(this); var args = reArguments.apply(null, arguments); + if (wicked && wicked.template === args[0]) { wicked.tagger.apply(null, args); } else { upgrade.apply(this, args); } - return this; - } - // an upgrade is in charge of collecting template info, + return this; + } // an upgrade is in charge of collecting template info, // parse it once, if unknown, to map all interpolations // as single DOM callbacks, relate such template // to the current context, and render it after cleaning the context up + + function upgrade() { var args = reArguments.apply(null, arguments); var type = OWNER_SVG_ELEMENT in this ? 'svg' : 'html'; var tagger = new Tagger(type); - bewitched.set(this, { tagger: tagger, template: args[0] }); + bewitched.set(this, { + tagger: tagger, + template: args[0] + }); this.textContent = ''; this.appendChild(tagger.apply(null, args)); } /*! (c) Andrea Giammarchi (ISC) */ - - // all functions are self bound to the right context // you can do the following // const {bind, wire} = hyperHTML; // and use them right away: bind(node)`hello!`; + var bind = function bind(context) { return render.bind(context); }; + var define = Intent.define; var tagger = Tagger.prototype; - hyper.Component = Component; hyper.bind = bind; hyper.define = define; @@ -1672,25 +1803,21 @@ var hyperHTML = (function (document) { hyper.hyper = hyper; hyper.observe = observe; hyper.tagger = tagger; - hyper.wire = wire; - - // exported as shared utils + hyper.wire = wire; // exported as shared utils // for projects based on hyperHTML // that don't necessarily need upfront polyfills // i.e. those still targeting IE + hyper._ = { - global: G, WeakMap: WeakMap$1, WeakSet: WeakSet$1 - }; - - // the wire content is the lazy defined + }; // the wire content is the lazy defined // html or svg property of each hyper.Component - setup(content); - // by default, hyperHTML is a smart function + setup(content); // everything is exported directly or through the // that "magically" understands what's the best // thing to do with passed arguments + function hyper(HTML) { return arguments.length < 2 ? HTML == null ? content('html') : typeof HTML === 'string' ? hyper.wire(null, HTML) : 'raw' in HTML ? content('html')(HTML) : 'nodeType' in HTML ? hyper.bind(HTML) : weakly(HTML, 'html') : ('raw' in HTML ? content('html') : hyper.wire).apply(null, arguments); } diff --git a/min.js b/min.js index 59da25ed..04d83777 100644 --- a/min.js +++ b/min.js @@ -1,3 +1,3 @@ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){return e.join(ee).replace(fe,o).replace(se,r)}function r(e,t,n,r){return"<"+t+n.replace(de,i)+r}function i(e,t,n){return t+(n||'"')+Y+(n||'"')}function o(e,t,n){return oe.test(t)?e:"<"+t+n+">"}function a(e,t,n,r){return{name:r,node:t,path:n,type:e}}function u(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},O=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Q=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),U=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==Y)})(e.createElement("template"))||(Y="_dt: "+Y.slice(1,-1)+";");var ee="\x3c!--"+Y+"--\x3e",te=8,ne=1,re=3,ie=/^(?:style|textarea)$/i,oe=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ae=" \\f\\n\\r\\t",ue="[ "+ae+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ce="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",le="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",se=new RegExp(ce+ue+le+"+)([ "+ae+"]*/?>)","g"),fe=new RegExp(ce+ue+le+"*)([ "+ae+"]*/>)","g"),de=new RegExp("("+ue+"\\s*=\\s*)(['\"]?)"+ee+"\\2","gi"),he=new y,ve=new y,pe=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),ge=e.defaultView,me="ownerSVGElement",be=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),we=function(e){return e.ownerDocument||e},ye=function(e){return we(e).createDocumentFragment()},Ne=function(e,t){return we(e).createTextNode(t)},xe="append"in ye(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"}function u(e,t,n,r){return{name:r,node:t,path:n,type:e}}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=o;ca;)--c;l=u+r-c;var g=Array(l),b=s[c];for(--n;b;){for(var y=b,w=y.newi,N=y.oldi;n>w;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=i;)g[--l]=-1,--a;return g},P=function(e,t,n,r,o,i,a){var u,c,l,s,f,h,d,p=n+i,v=[];e:for(u=0;u<=p;u++){if(u>50)return null;for(d=u-1,f=u?v[u-1]:[0,0],h=v[u]=[],c=-u;c<=u;c+=2){for(s=c===-u||c!==u&&f[d+c-1]=0;u--){for(;s>0&&l>0&&a(r[o+s-1],e[t+l-1]);)m[g--]=0,s--,l--;if(!u)break;d=u-1,f=u?v[u-1]:[0,0],c=s-l,c===-u||c!==u&&f[d+c-1]>>0;n",t(r,i.firstChild.childNodes),r}var o="fragment",i="content"in n("template"),a=i?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(o),i=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;i.innerHTML=""+e+"
",a=i.querySelectorAll(u)}else i.innerHTML=e,a=i.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),U=function(e,t,n,r,o){var i="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(i?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],o=r.length,i=0;t&&i

',e.content.childNodes[0].getAttribute("tabindex")==Y)})(e.createElement("template"))||(Y="_dt: "+Y.slice(1,-1)+";");var ee="\x3c!--"+Y+"--\x3e",te=8,ne=1,re=3,oe=/^(?:style|textarea)$/i,ie=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ae=" \\f\\n\\r\\t",ue="[ "+ae+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ce="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",le="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",se=new RegExp(ce+ue+le+"+)([ "+ae+"]*/?>)","g"),fe=new RegExp(ce+ue+le+"*)([ "+ae+"]*/>)","g"),he=new RegExp("("+ue+"\\s*=\\s*)(['\"]?)"+ee+"\\2","gi"),de=new N,pe=new N,ve=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function n(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),o(n,!0)}function r(t){var n,r=[];for(n in t)r.push(n.replace(a,e),":",t[n],";");return r.join("")}function o(e,n){var o,a;return function(u){var c,l,s,f;switch(t(u)){case"object":if(u){if("object"===o){if(!n&&a!==u)for(l in a)l in u||(e[l]="")}else n?e.value="":e.cssText="";c=n?{}:e;for(l in u)f=u[l],s="number"!=typeof f||i.test(l)?f:f+"px",!n&&/^--/.test(l)?c.setProperty(l,s):c[l]=s;o="object",n?e.value=r(a=c):a=u;break}default:a!=u&&(o="string",a=u,n?e.value=u||"":e.cssText=u||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,a=/([^A-Z])([A-Z]+)/g;return function(e,t){return"ownerSVGElement"in e?n(e,t):o(e.style,!1)}}(),me="ownerSVGElement",ge=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var o={};return(n=function(e){var t="raw"+e.join("raw");return o[t]||(o[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),be=function(e){return e.ownerDocument||e},ye=function(e){return be(e).createDocumentFragment()},we=function(e,t){return be(e).createTextNode(t)},Ne="append"in ye(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r index.clean" ], "mv index.clean index.js" @@ -119,27 +120,15 @@ "url": "https://github.com/WebReflection/hyperhtml/issues" }, "devDependencies": { + "@babel/core": "^7.2.2", + "@babel/preset-env": "^7.2.0", "ascjs": "^2.4.0", - "babel-cli": "^6.26.0", - "babel-plugin-check-es2015-constants": "^6.22.0", - "babel-plugin-transform-es2015-arrow-functions": "^6.22.0", - "babel-plugin-transform-es2015-block-scoped-functions": "^6.22.0", - "babel-plugin-transform-es2015-block-scoping": "^6.26.0", - "babel-plugin-transform-es2015-classes": "^6.24.1", - "babel-plugin-transform-es2015-computed-properties": "^6.24.1", - "babel-plugin-transform-es2015-destructuring": "^6.23.0", - "babel-plugin-transform-es2015-duplicate-keys": "^6.24.1", - "babel-plugin-transform-es2015-function-name": "^6.24.1", - "babel-plugin-transform-es2015-literals": "^6.22.0", - "babel-plugin-transform-es2015-shorthand-properties": "^6.24.1", - "babel-plugin-transform-es2015-spread": "^6.22.0", - "babel-plugin-transform-es2015-template-literals": "^6.22.0", "basichtml": "^0.20.2", "coveralls": "^3.0.2", "istanbul": "^0.4.5", "npm-dollar": "^2.1.3", "rollup": "^0.67.0", - "rollup-plugin-babel": "^3.0.7", + "rollup-plugin-babel": "^4.1.0", "rollup-plugin-node-resolve": "^4.0.0", "tressa": "^0.3.1", "uglify-js": "^2.8.29" @@ -151,7 +140,7 @@ ] }, "dependencies": { - "@ungap/create-content": "^0.1.1", + "@ungap/create-content": "^0.1.4", "@ungap/custom-event": "^0.2.0", "@ungap/essential-map": "^0.1.7", "@ungap/essential-weakset": "^0.1.2", diff --git a/rollup.config.js b/rollup.config.js index f38cce83..65f24dc2 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,15 +1,11 @@ -import babel from 'rollup-plugin-babel'; import resolve from 'rollup-plugin-node-resolve'; +import babel from 'rollup-plugin-babel'; export default { input: 'esm/index.js', plugins: [ - resolve({ - module: true - }), - babel({ - plugins: require('./babel-plugins.json') - }) + resolve({module: true}), + babel({presets: ["@babel/preset-env"]}) ], context: 'null', moduleContext: 'null', diff --git a/umd.js b/umd.js index 7630debe..c69c12fd 100644 --- a/umd.js +++ b/umd.js @@ -1,5 +1,5 @@ (function(A,G){if(typeof define=='function'&&define.amd)define([],G);else if(typeof module=='object'&&module.exports)module.exports=G();else A.hyperHTML=G()}(typeof self!='undefined'?self:this,function(){ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){return e.join(ee).replace(fe,o).replace(se,r)}function r(e,t,n,r){return"<"+t+n.replace(de,i)+r}function i(e,t,n){return t+(n||'"')+Y+(n||'"')}function o(e,t,n){return oe.test(t)?e:"<"+t+n+">"}function a(e,t,n,r){return{name:r,node:t,path:n,type:e}}function u(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=i;ca;)--c;l=u+r-c;var m=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)m[--l]=1,--n;for(;a>N;)m[--l]=-1,--a;m[--l]=0,--n,--a,b=b.prev}for(;n>=t;)m[--l]=1,--n;for(;a>=o;)m[--l]=-1,--a;return m},O=function(e,t,n,r,i,o,a){var u=n+o,c=[],l=void 0,s=void 0,f=void 0,d=void 0,h=void 0,v=void 0,p=void 0;e:for(l=0;l<=u;l++){if(l>50)return null;for(p=l-1,h=l?c[l-1]:[0,0],v=c[l]=[],s=-l;s<=l;s+=2){for(d=s===-l||s!==l&&h[p+s-1]=0;l--){for(;d>0&&f>0&&a(r[i+d-1],e[t+f-1]);)g[m--]=0,d--,f--;if(!l)break;p=l-1,h=l?c[l-1]:[0,0],s=d-f,s===-l||s!==l&&h[p+s-1]>>0;n",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),Q=function(e){function t(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function n(t){return t===i?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function r(e){var r=n(i),o=n("div");return o.innerHTML=''+e+"",t(r,o.firstChild.childNodes),r}var i="fragment",o="content"in n("template"),a=o?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(i),o=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;o.innerHTML=""+e+"
",a=o.querySelectorAll(u)}else o.innerHTML=e,a=o.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),U=function(e,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==Y)})(e.createElement("template"))||(Y="_dt: "+Y.slice(1,-1)+";");var ee="\x3c!--"+Y+"--\x3e",te=8,ne=1,re=3,ie=/^(?:style|textarea)$/i,oe=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ae=" \\f\\n\\r\\t",ue="[ "+ae+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ce="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",le="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",se=new RegExp(ce+ue+le+"+)([ "+ae+"]*/?>)","g"),fe=new RegExp(ce+ue+le+"*)([ "+ae+"]*/>)","g"),de=new RegExp("("+ue+"\\s*=\\s*)(['\"]?)"+ee+"\\2","gi"),he=new y,ve=new y,pe=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function t(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),r(n,!0)}function n(t){var n,r=[];for(n in t)r.push(n.replace(o,e),":",t[n],";");return r.join("")}function r(e,t){var r,o;return function(a){var u,c,l,s;switch(typeof a){case"object":if(a){if("object"===r){if(!t&&o!==a)for(c in o)c in a||(e[c]="")}else t?e.value="":e.cssText="";u=t?{}:e;for(c in a)s=a[c],l="number"!=typeof s||i.test(c)?s:s+"px",!t&&/^--/.test(c)?u.setProperty(c,l):u[c]=l;r="object",t?e.value=n(o=u):o=a;break}default:o!=a&&(r="string",o=a,t?e.value=a||"":e.cssText=a||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,o=/([^A-Z])([A-Z]+)/g;return function(e,n){return"ownerSVGElement"in e?t(e,n):r(e.style,!1)}}(),ge=e.defaultView,me="ownerSVGElement",be=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var i={};return(n=function(e){var t="raw"+e.join("raw");return i[t]||(i[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),we=function(e){return e.ownerDocument||e},ye=function(e){return we(e).createDocumentFragment()},Ne=function(e,t){return we(e).createTextNode(t)},xe="append"in ye(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r"}function u(e,t,n,r){return{name:r,node:t,path:n,type:e}}function c(e,t){for(var n=t.length,r=0;r=u;){for(var c=t,l=o;ca;)--c;l=u+r-c;var g=Array(l),b=s[c];for(--n;b;){for(var y=b,w=y.newi,N=y.oldi;n>w;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=i;)g[--l]=-1,--a;return g},P=function(e,t,n,r,o,i,a){var u,c,l,s,f,h,d,p=n+i,v=[];e:for(u=0;u<=p;u++){if(u>50)return null;for(d=u-1,f=u?v[u-1]:[0,0],h=v[u]=[],c=-u;c<=u;c+=2){for(s=c===-u||c!==u&&f[d+c-1]=0;u--){for(;s>0&&l>0&&a(r[o+s-1],e[t+l-1]);)m[g--]=0,s--,l--;if(!u)break;d=u-1,f=u?v[u-1]:[0,0],c=s-l,c===-u||c!==u&&f[d+c-1]>>0;n",t(r,i.firstChild.childNodes),r}var o="fragment",i="content"in n("template"),a=i?function(e){var t=n("template");return t.innerHTML=e,t.content}:function(e){var r=n(o),i=n("template"),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var u=RegExp.$1;i.innerHTML=""+e+"
",a=i.querySelectorAll(u)}else i.innerHTML=e,a=i.childNodes;return t(r,a),r};return function(e,t){return("svg"===t?r:a)(e)}}(e),U=function(e,t,n,r,o){var i="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(i?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],o=r.length,i=0;t&&i

',e.content.childNodes[0].getAttribute("tabindex")==Y)})(e.createElement("template"))||(Y="_dt: "+Y.slice(1,-1)+";");var ee="\x3c!--"+Y+"--\x3e",te=8,ne=1,re=3,oe=/^(?:style|textarea)$/i,ie=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ae=" \\f\\n\\r\\t",ue="[ "+ae+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ce="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",le="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",se=new RegExp(ce+ue+le+"+)([ "+ae+"]*/?>)","g"),fe=new RegExp(ce+ue+le+"*)([ "+ae+"]*/>)","g"),he=new RegExp("("+ue+"\\s*=\\s*)(['\"]?)"+ee+"\\2","gi"),de=new N,pe=new N,ve=function(){function e(e,t,n){return t+"-"+n.toLowerCase()}function n(e,t){var n;return t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style")),n.value="",e.setAttributeNode(n),o(n,!0)}function r(t){var n,r=[];for(n in t)r.push(n.replace(a,e),":",t[n],";");return r.join("")}function o(e,n){var o,a;return function(u){var c,l,s,f;switch(t(u)){case"object":if(u){if("object"===o){if(!n&&a!==u)for(l in a)l in u||(e[l]="")}else n?e.value="":e.cssText="";c=n?{}:e;for(l in u)f=u[l],s="number"!=typeof f||i.test(l)?f:f+"px",!n&&/^--/.test(l)?c.setProperty(l,s):c[l]=s;o="object",n?e.value=r(a=c):a=u;break}default:a!=u&&(o="string",a=u,n?e.value=u||"":e.cssText=u||"")}}}var i=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,a=/([^A-Z])([A-Z]+)/g;return function(e,t){return"ownerSVGElement"in e?n(e,t):o(e.style,!1)}}(),me="ownerSVGElement",ge=function(){var t=!1,n=function(r){if(!("raw"in r)||r.propertyIsEnumerable("raw")||!Object.isFrozen(r.raw)||/Firefox\/(\d+)/.test((e.defaultView.navigator||{}).userAgent)&&parseFloat(RegExp.$1)<55){var o={};return(n=function(e){var t="raw"+e.join("raw");return o[t]||(o[t]=e)})(r)}return t=!0,r};return function(e){return t?e:n(e)}}(),be=function(e){return e.ownerDocument||e},ye=function(e){return be(e).createDocumentFragment()},we=function(e,t){return be(e).createTextNode(t)},Ne="append"in ye(e)?function(e,t){e.append.apply(e,t)}:function(e,t){for(var n=t.length,r=0;r Date: Mon, 17 Dec 2018 18:31:06 +0700 Subject: [PATCH 038/151] 2.23.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index efe12a74..5eb3c8ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hyperhtml", - "version": "2.22.1", + "version": "2.23.0", "description": "A Fast & Light Virtual DOM Alternative", "homepage": "https://viperhtml.js.org/hyper.html", "unpkg": "min.js", From 98693d09413cd7f6313eb7b1e20338b28a563044 Mon Sep 17 00:00:00 2001 From: Andrea Giammarchi Date: Tue, 18 Dec 2018 08:00:16 +0700 Subject: [PATCH 039/151] fixed IE < 11 tests --- package.json | 5 +- rollup.ie.js | 16 + test/ie/index.html | 5 +- test/ie/test/test.js | 4222 +++++++++++++++++++++++++++++------------- 4 files changed, 2926 insertions(+), 1322 deletions(-) create mode 100644 rollup.ie.js diff --git a/package.json b/package.json index 5eb3c8ee..ee5061ac 100644 --- a/package.json +++ b/package.json @@ -30,9 +30,7 @@ ], "ie": [ [ - "babel ./test/test.js --out-dir ./test/ie --plugins=$(", - "node -e 'console.log([\"transform-es2015-classes\", \"transform-es2015-template-literals\"].concat(require(\"./babel-plugins.json\")).join(\",\")", - ")')" + "rollup --config rollup.ie.js" ] ], "umd": [ @@ -61,6 +59,7 @@ "$ bundle.min", "$ bundle.umd", "$ bundle.esm", + "$ bundle.ie", "$ test", "$ size" ], diff --git a/rollup.ie.js b/rollup.ie.js new file mode 100644 index 00000000..3f1c1a3f --- /dev/null +++ b/rollup.ie.js @@ -0,0 +1,16 @@ +import resolve from 'rollup-plugin-node-resolve'; +import babel from 'rollup-plugin-babel'; + +export default { + input: 'test/test.js', + plugins: [ + resolve({module: true}), + babel({presets: ["@babel/preset-env"]}) + ], + context: 'null', + moduleContext: 'null', + output: { + file: 'test/ie/test/test.js', + format: 'iife' + } +}; diff --git a/test/ie/index.html b/test/ie/index.html index de4c8248..1dfef24b 100644 --- a/test/ie/index.html +++ b/test/ie/index.html @@ -11,13 +11,16 @@ + - +

results in console

diff --git a/test/ie/test/test.js b/test/ie/test/test.js index a65db291..ce7e0f2b 100644 --- a/test/ie/test/test.js +++ b/test/ie/test/test.js @@ -1,1482 +1,3068 @@ -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -var _templateObject = _taggedTemplateLiteral(['\n

\n Time: ', '\n

\n '], ['\n

\n Time: ', '\n

\n ']), - _templateObject2 = _taggedTemplateLiteral(['

', ' world

'], ['

', ' world

']), - _templateObject3 = _taggedTemplateLiteral(['

', '

'], ['

', '

']), - _templateObject4 = _taggedTemplateLiteral(['click'], ['click']), - _templateObject5 = _taggedTemplateLiteral(['how cool'], ['how cool']), - _templateObject6 = _taggedTemplateLiteral(['\n

1

\n

2

\n '], ['\n

1

\n

2

\n ']), - _templateObject7 = _taggedTemplateLiteral(['\n

1

\n

2

\n

3

\n '], ['\n

1

\n

2

\n

3

\n ']), - _templateObject8 = _taggedTemplateLiteral(['

OK

'], ['

OK

']), - _templateObject9 = _taggedTemplateLiteral(['\n

1

\n '], ['\n

1

\n ']), - _templateObject10 = _taggedTemplateLiteral(['\n 0\n

1

\n '], ['\n 0\n

1

\n ']), - _templateObject11 = _taggedTemplateLiteral(['', ''], ['', '']), - _templateObject12 = _taggedTemplateLiteral(['a'], ['a']), - _templateObject13 = _taggedTemplateLiteral(['\n O'], ['\n O']), - _templateObject14 = _taggedTemplateLiteral(['\n
\n
    ', '
\n
'], ['\n
\n
    ', '
\n
']), - _templateObject15 = _taggedTemplateLiteral(['\n
  • ', '
  • \n '], ['\n
  • ', '
  • \n ']), - _templateObject16 = _taggedTemplateLiteral(['
    ', '
    '], ['
    ', '
    ']), - _templateObject17 = _taggedTemplateLiteral([''], ['']), - _templateObject18 = _taggedTemplateLiteral(['

    '], ['

    ']), - _templateObject19 = _taggedTemplateLiteral(['

    ', '

    ', '
    ', '
    ', ''], ['

    ', '

    ', '
    ', '
    ', '']), - _templateObject20 = _taggedTemplateLiteral([''], ['']), - _templateObject21 = _taggedTemplateLiteral(['
    ', ''], ['
    ', '']), - _templateObject22 = _taggedTemplateLiteral(['', '
    '], ['', '
    ']), - _templateObject23 = _taggedTemplateLiteral([''], ['']), - _templateObject24 = _taggedTemplateLiteral(['a=', ''], ['a=', '']), - _templateObject25 = _taggedTemplateLiteral(['[', ']'], ['[', ']']), - _templateObject26 = _taggedTemplateLiteral(['

    '], ['

    ']), - _templateObject27 = _taggedTemplateLiteral(['
    ', '
    '], ['
    ', '
    ']), - _templateObject28 = _taggedTemplateLiteral([''], ['']), - _templateObject29 = _taggedTemplateLiteral([''], ['']), - _templateObject30 = _taggedTemplateLiteral([''], ['']), - _templateObject31 = _taggedTemplateLiteral(['ok'], ['ok']), - _templateObject32 = _taggedTemplateLiteral(['
    ', '
    '], ['
    ', '
    ']), - _templateObject33 = _taggedTemplateLiteral([''], ['']), - _templateObject34 = _taggedTemplateLiteral(['

    '], ['

    ']), - _templateObject35 = _taggedTemplateLiteral(['

    ', '

    '], ['

    ', '

    ']), - _templateObject36 = _taggedTemplateLiteral([''], ['']), - _templateObject37 = _taggedTemplateLiteral(['

    '], ['

    ']), - _templateObject38 = _taggedTemplateLiteral([''], ['']), - _templateObject39 = _taggedTemplateLiteral([''], ['']), - _templateObject40 = _taggedTemplateLiteral(['\n '], ['\n ']), - _templateObject41 = _taggedTemplateLiteral(['\n
    First name: ', '
    \n

    '], ['\n
    First name: ', '
    \n

    ']), - _templateObject42 = _taggedTemplateLiteral(['\n

    ', ''], ['\n

    ', '']), - _templateObject43 = _taggedTemplateLiteral(['\n

    ', ''], ['\n

    ', '']), - _templateObject44 = _taggedTemplateLiteral([''], ['']), - _templateObject45 = _taggedTemplateLiteral(['

    '], ['

    ']), - _templateObject46 = _taggedTemplateLiteral(['

    '], ['

    ']), - _templateObject47 = _taggedTemplateLiteral(['a ', ''], ['a ', '']), - _templateObject48 = _taggedTemplateLiteral(['

    any content

    '], ['

    any content

    ']), - _templateObject49 = _taggedTemplateLiteral([''], ['']), - _templateObject50 = _taggedTemplateLiteral(['abc'], ['abc']), - _templateObject51 = _taggedTemplateLiteral(['

    a', 'c

    '], ['

    a', 'c

    ']), - _templateObject52 = _taggedTemplateLiteral(['a', 'c'], ['a', 'c']), - _templateObject53 = _taggedTemplateLiteral([''], ['']), - _templateObject54 = _taggedTemplateLiteral(['
    abc
    '], ['
    abc
    ']), - _templateObject55 = _taggedTemplateLiteral(['\n '], ['\n ']), - _templateObject56 = _taggedTemplateLiteral(['\n '], ['\n ']), - _templateObject57 = _taggedTemplateLiteral(['\n

    hello

    '], ['\n

    hello

    ']), - _templateObject58 = _taggedTemplateLiteral(['\n

    hello

    '], ['\n

    hello

    ']), - _templateObject59 = _taggedTemplateLiteral(['
    \n \n
    '], ['
    \n \n
    ']), - _templateObject60 = _taggedTemplateLiteral(['
      \n ', '\n
    '], ['
      \n ', '\n
    ']), - _templateObject61 = _taggedTemplateLiteral(['
  • ', '
  • '], ['
  • ', '
  • ']), - _templateObject62 = _taggedTemplateLiteral(['\n

    hello

    '], ['\n

    hello

    ']), - _templateObject63 = _taggedTemplateLiteral(['

    '], ['

    ']), - _templateObject64 = _taggedTemplateLiteral(['
    '], ['
    ']), - _templateObject65 = _taggedTemplateLiteral(['
    \n \n
    '], ['
    \n \n
    ']), - _templateObject66 = _taggedTemplateLiteral(['\n
    \n \n \n \n \n
    \n '], ['\n
    \n \n \n \n \n
    \n ']), - _templateObject67 = _taggedTemplateLiteral(['\n
    \n