From 7086b09b7f07bd4f6a50788197c2f48f7b73e765 Mon Sep 17 00:00:00 2001 From: Andrea Giammarchi Date: Mon, 17 Dec 2018 10:03:47 +0800 Subject: [PATCH 01/38] 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 02/38] 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 03/38] 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 04/38] 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 05/38] 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 06/38] 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 07/38] 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 08/38] 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