From 4cf0bfeac6e4bab55fdcb45ac8c9d5e277384db5 Mon Sep 17 00:00:00 2001 From: Andrea Giammarchi Date: Fri, 11 Jan 2019 09:18:18 +0100 Subject: [PATCH] using @ungap/template-tag-arguments instead of @ungap/template-literal --- cjs/hyper/render.js | 4 +- cjs/hyper/wire.js | 4 +- cjs/objects/Updates.js | 7 ++- cjs/shared/utils.js | 19 -------- esm.js | 7 +-- esm/hyper/render.js | 4 +- esm/hyper/wire.js | 4 +- esm/objects/Updates.js | 7 ++- esm/shared/utils.js | 16 ------ index.js | 108 ++++++++++++++++++++++------------------- min.js | 7 +-- package.json | 5 +- umd.js | 7 +-- 13 files changed, 92 insertions(+), 107 deletions(-) delete mode 100644 esm/shared/utils.js diff --git a/cjs/hyper/render.js b/cjs/hyper/render.js index 4b62eeec..a401a66b 100644 --- a/cjs/hyper/render.js +++ b/cjs/hyper/render.js @@ -1,9 +1,9 @@ 'use strict'; const WeakMap = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/weakmap')); +const tta = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/template-tag-arguments')); const {OWNER_SVG_ELEMENT} = require('../shared/constants.js'); const {Tagger} = require('../objects/Updates.js'); -const {reArguments} = require('../shared/utils.js'); // a weak collection of contexts that // are already known to hyperHTML @@ -15,7 +15,7 @@ const bewitched = new WeakMap; // The `this` context is either a regular DOM node or a fragment. function render() { const wicked = bewitched.get(this); - const args = reArguments.apply(null, arguments); + const args = tta.apply(null, arguments); if (wicked && wicked.template === args[0]) { wicked.tagger.apply(null, args); } else { diff --git a/cjs/hyper/wire.js b/cjs/hyper/wire.js index 39e62547..139eaaba 100644 --- a/cjs/hyper/wire.js +++ b/cjs/hyper/wire.js @@ -1,10 +1,10 @@ 'use strict'; const WeakMap = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/weakmap')); +const tta = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/template-tag-arguments')); const Wire = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('hyperhtml-wire')); const {Tagger} = require('../objects/Updates.js'); -const {reArguments} = require('../shared/utils.js'); // all wires used per each context const wires = new WeakMap; @@ -31,7 +31,7 @@ const wire = (obj, type) => obj == null ? const content = type => { let wire, tagger, template; return function () { - const args = reArguments.apply(null, arguments); + const args = tta.apply(null, arguments); if (template !== args[0]) { template = args[0]; tagger = new Tagger(type); diff --git a/cjs/objects/Updates.js b/cjs/objects/Updates.js index b24a2e60..75dcf36c 100644 --- a/cjs/objects/Updates.js +++ b/cjs/objects/Updates.js @@ -16,7 +16,6 @@ const { const Component = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('../classes/Component.js')); const Wire = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('hyperhtml-wire')); const Intent = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('./Intent.js')); -const { slice, text } = require('../shared/utils.js'); const observe = disconnected({Event: CustomEvent, WeakSet}); @@ -70,6 +69,12 @@ const isPromise_ish = value => value != null && 'then' in value; // list of attributes that should not be directly assigned const readOnly = /^(?:form|list)$/i; +// reused every slice time +const slice = [].slice; + +// simplifies text node creation +const text = (node, text) => node.ownerDocument.createTextNode(text); + function Tagger(type) { this.type = type; return domtagger(this); diff --git a/cjs/shared/utils.js b/cjs/shared/utils.js index 60200eba..ad9a93a7 100644 --- a/cjs/shared/utils.js +++ b/cjs/shared/utils.js @@ -1,20 +1 @@ 'use strict'; -const unique = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/template-literal')); - -// these are tiny helpers to simplify most common operations needed here -const text = (node, text) => node.ownerDocument.createTextNode(text); -exports.text = text; - -// normalizes the template once for all arguments cases -const reArguments = function (template) { - const args = [unique(template)]; - for (let i = 1, length = arguments.length; i < length; i++) - args[i] = arguments[i]; - return args; -} -exports.reArguments = reArguments - -// just recycling a one-off array to use slice -// in every needed place -const slice = [].slice; -exports.slice = slice; diff --git a/esm.js b/esm.js index 0a8d613d..15f491c4 100644 --- a/esm.js +++ b/esm.js @@ -1,5 +1,6 @@ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){return e.join(X).replace(le,o).replace(ce,r)}function r(e,t,n,r){return"<"+t+n.replace(se,i)+r}function i(e,t,n){return t+(n||'"')+U+(n||'"')}function o(e,t,n){return re.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 g=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},O=function(e,t,n,r,i,o,a){var u,c,l,s,f,h,d,v=n+o,p=[];e:for(u=0;u<=v;u++){if(u>50)return null;for(d=u-1,f=u?p[u-1]:[0,0],h=p[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[i+s-1],e[t+l-1]);)m[g--]=0,s--,l--;if(!u)break;d=u-1,f=u?p[u-1]:[0,0],c=s-l,c===-u||c!==u&&f[d+c-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),K=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")==U)})(e.createElement("template"))||(U="_dt: "+U.slice(1,-1)+";");var X="\x3c!--"+U+"--\x3e",Y=8,ee=1,te=3,ne=/^(?:style|textarea)$/i,re=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ie=" \\f\\n\\r\\t",oe="[ "+ie+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ae="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",ue="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",ce=new RegExp(ae+oe+ue+"+)([ "+ie+"]*/?>)","g"),le=new RegExp(ae+oe+ue+"*)([ "+ie+"]*/>)","g"),se=new RegExp("("+oe+"\\s*=\\s*)(['\"]?)"+X+"\\2","gi"),fe=new w,he=new w,de=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)}}(),ve="ownerSVGElement",pe=function(e,t){function n(t){var n=this.childNodes=e.call(t,0);this.firstChild=n[0],this.lastChild=n[n.length-1],this.ownerDocument=n[0].ownerDocument,this._=null}return t=n.prototype,t.remove=function(e){var t=this.childNodes,n=this.firstChild,r=this.lastChild;if(this._=null,e&&2===t.length)r.parentNode.removeChild(r);else{var i=this.ownerDocument.createRange();i.setStartBefore(e?t[1]:n),i.setEndAfter(r),i.deleteContents()}return n},t.valueOf=function(e){var t=this._,n=null==t;if(n&&(t=this._=this.ownerDocument.createDocumentFragment()),n||e)for(var r=this.childNodes,i=0,o=r.length;i"}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 g=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},L=function(e,t,n,r,i,o,a){var u,c,l,s,f,h,d,v=n+o,p=[];e:for(u=0;u<=v;u++){if(u>50)return null;for(d=u-1,f=u?p[u-1]:[0,0],h=p[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[i+s-1],e[t+l-1]);)m[g--]=0,s--,l--;if(!u)break;d=u-1,f=u?p[u-1]:[0,0],c=s-l,c===-u||c!==u&&f[d+c-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,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==X)})(e.createElement("template"))||(X="_dt: "+X.slice(1,-1)+";");var Y="\x3c!--"+X+"--\x3e",ee=8,te=1,ne=3,re=/^(?:style|textarea)$/i,ie=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,oe=" \\f\\n\\r\\t",ae="[ "+oe+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ue="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",ce="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",le=new RegExp(ue+ae+ce+"+)([ "+oe+"]*/?>)","g"),se=new RegExp(ue+ae+ce+"*)([ "+oe+"]*/>)","g"),fe=new RegExp("("+ae+"\\s*=\\s*)(['\"]?)"+Y+"\\2","gi"),he=new y,de=new y,ve=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)}}(),pe="ownerSVGElement",me=function(e,t){function n(t){var n=this.childNodes=e.call(t,0);this.firstChild=n[0],this.lastChild=n[n.length-1],this.ownerDocument=n[0].ownerDocument,this._=null}return t=n.prototype,t.remove=function(e){var t=this.childNodes,n=this.firstChild,r=this.lastChild;if(this._=null,e&&2===t.length)r.parentNode.removeChild(r);else{var i=this.ownerDocument.createRange();i.setStartBefore(e?t[1]:n),i.setEndAfter(r),i.deleteContents()}return n},t.valueOf=function(e){var t=this._,n=null==t;if(n&&(t=this._=this.ownerDocument.createDocumentFragment()),n||e)for(var r=this.childNodes,i=0,o=r.length;i obj == null ? const content = type => { let wire, tagger, template; return function () { - const args = reArguments.apply(null, arguments); + const args = tta.apply(null, arguments); if (template !== args[0]) { template = args[0]; tagger = new Tagger(type); diff --git a/esm/objects/Updates.js b/esm/objects/Updates.js index 945c7f35..b481c370 100644 --- a/esm/objects/Updates.js +++ b/esm/objects/Updates.js @@ -17,7 +17,6 @@ import { import Component from '../classes/Component.js'; import Wire from 'hyperhtml-wire'; import Intent from './Intent.js'; -import { slice, text } from '../shared/utils.js'; const observe = disconnected({Event: CustomEvent, WeakSet}); @@ -70,6 +69,12 @@ const isPromise_ish = value => value != null && 'then' in value; // list of attributes that should not be directly assigned const readOnly = /^(?:form|list)$/i; +// reused every slice time +const slice = [].slice; + +// simplifies text node creation +const text = (node, text) => node.ownerDocument.createTextNode(text); + function Tagger(type) { this.type = type; return domtagger(this); diff --git a/esm/shared/utils.js b/esm/shared/utils.js deleted file mode 100644 index d2de2957..00000000 --- a/esm/shared/utils.js +++ /dev/null @@ -1,16 +0,0 @@ -import unique from '@ungap/template-literal'; - -// these are tiny helpers to simplify most common operations needed here -export const text = (node, text) => node.ownerDocument.createTextNode(text); - -// normalizes the template once for all arguments cases -export const reArguments = function (template) { - const args = [unique(template)]; - for (let i = 1, length = arguments.length; i < length; i++) - args[i] = arguments[i]; - return args; -} - -// just recycling a one-off array to use slice -// in every needed place -export const slice = [].slice; diff --git a/index.js b/index.js index cb83fb51..f1619f6b 100644 --- a/index.js +++ b/index.js @@ -1322,53 +1322,6 @@ var hyperHTML = (function (document) { } }([].slice); - var templateLiteral = function () { - - 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 - /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); - }; - }(); - - var text = function text(node, _text) { - return node.ownerDocument.createTextNode(_text); - }; // 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 - // in every needed place - - var slice = [].slice; - var observe = disconnected({ Event: CustomEvent$1, WeakSet: WeakSet$1 @@ -1419,7 +1372,13 @@ var hyperHTML = (function (document) { }; // list of attributes that should not be directly assigned - var readOnly = /^(?:form|list)$/i; + var readOnly = /^(?:form|list)$/i; // reused every slice time + + var slice = [].slice; // simplifies text node creation + + var text = function text(node, _text) { + return node.ownerDocument.createTextNode(_text); + }; function Tagger(type) { this.type = type; @@ -1625,7 +1584,7 @@ var hyperHTML = (function (document) { // 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) { + text: function text(node) { var oldValue; var textContent = function textContent(value) { @@ -1662,6 +1621,53 @@ var hyperHTML = (function (document) { } }; + /*! (c) Andrea Giammarchi - ISC */ + var templateLiteral = function () { + + 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 + /Firefox\/(\d+)/.test((document.defaultView.navigator || {}).userAgent) && parseFloat(RegExp.$1) < 55) { + var forever = {}; + + _templateLiteral = function templateLiteral(tl) { + for (var key = '.', i = 0; i < tl.length; i++) { + key += tl[i].length + '.' + tl[i]; + } + + return forever[key] || (forever[key] = tl); + }; + } else { + isNoOp = true; + } + + return TL(tl); + }; + + return TL; + + function TL(tl) { + return isNoOp ? tl : _templateLiteral(tl); + } + }(); + + function tta (template) { + var length = arguments.length; + var args = [templateLiteral(template)]; + var i = 1; + + while (i < length) { + args.push(arguments[i++]); + } + + return args; + } + 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 @@ -1685,7 +1691,7 @@ var hyperHTML = (function (document) { var content = function content(type) { var wire, tagger, template; return function () { - var args = reArguments.apply(null, arguments); + var args = tta.apply(null, arguments); if (template !== args[0]) { template = args[0]; @@ -1743,7 +1749,7 @@ var hyperHTML = (function (document) { function render() { var wicked = bewitched.get(this); - var args = reArguments.apply(null, arguments); + var args = tta.apply(null, arguments); if (wicked && wicked.template === args[0]) { wicked.tagger.apply(null, args); diff --git a/min.js b/min.js index d530ac6d..220a8041 100644 --- a/min.js +++ b/min.js @@ -1,3 +1,4 @@ -/*! (c) Andrea Giammarchi (ISC) */var hyperHTML=function(e){"use strict";function t(){return this}function n(e){return e.join(X).replace(le,o).replace(ce,r)}function r(e,t,n,r){return"<"+t+n.replace(se,i)+r}function i(e,t,n){return t+(n||'"')+U+(n||'"')}function o(e,t,n){return re.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 g=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},O=function(e,t,n,r,i,o,a){var u,c,l,s,f,h,d,v=n+o,p=[];e:for(u=0;u<=v;u++){if(u>50)return null;for(d=u-1,f=u?p[u-1]:[0,0],h=p[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[i+s-1],e[t+l-1]);)m[g--]=0,s--,l--;if(!u)break;d=u-1,f=u?p[u-1]:[0,0],c=s-l,c===-u||c!==u&&f[d+c-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),K=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")==U)})(e.createElement("template"))||(U="_dt: "+U.slice(1,-1)+";");var X="\x3c!--"+U+"--\x3e",Y=8,ee=1,te=3,ne=/^(?:style|textarea)$/i,re=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ie=" \\f\\n\\r\\t",oe="[ "+ie+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ae="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",ue="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",ce=new RegExp(ae+oe+ue+"+)([ "+ie+"]*/?>)","g"),le=new RegExp(ae+oe+ue+"*)([ "+ie+"]*/>)","g"),se=new RegExp("("+oe+"\\s*=\\s*)(['\"]?)"+X+"\\2","gi"),fe=new w,he=new w,de=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)}}(),ve="ownerSVGElement",pe=function(e,t){function n(t){var n=this.childNodes=e.call(t,0);this.firstChild=n[0],this.lastChild=n[n.length-1],this.ownerDocument=n[0].ownerDocument,this._=null}return t=n.prototype,t.remove=function(e){var t=this.childNodes,n=this.firstChild,r=this.lastChild;if(this._=null,e&&2===t.length)r.parentNode.removeChild(r);else{var i=this.ownerDocument.createRange();i.setStartBefore(e?t[1]:n),i.setEndAfter(r),i.deleteContents()}return n},t.valueOf=function(e){var t=this._,n=null==t;if(n&&(t=this._=this.ownerDocument.createDocumentFragment()),n||e)for(var r=this.childNodes,i=0,o=r.length;i"}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 g=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},L=function(e,t,n,r,i,o,a){var u,c,l,s,f,h,d,v=n+o,p=[];e:for(u=0;u<=v;u++){if(u>50)return null;for(d=u-1,f=u?p[u-1]:[0,0],h=p[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[i+s-1],e[t+l-1]);)m[g--]=0,s--,l--;if(!u)break;d=u-1,f=u?p[u-1]:[0,0],c=s-l,c===-u||c!==u&&f[d+c-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,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==X)})(e.createElement("template"))||(X="_dt: "+X.slice(1,-1)+";");var Y="\x3c!--"+X+"--\x3e",ee=8,te=1,ne=3,re=/^(?:style|textarea)$/i,ie=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,oe=" \\f\\n\\r\\t",ae="[ "+oe+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ue="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",ce="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",le=new RegExp(ue+ae+ce+"+)([ "+oe+"]*/?>)","g"),se=new RegExp(ue+ae+ce+"*)([ "+oe+"]*/>)","g"),fe=new RegExp("("+ae+"\\s*=\\s*)(['\"]?)"+Y+"\\2","gi"),he=new y,de=new y,ve=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)}}(),pe="ownerSVGElement",me=function(e,t){function n(t){var n=this.childNodes=e.call(t,0);this.firstChild=n[0],this.lastChild=n[n.length-1],this.ownerDocument=n[0].ownerDocument,this._=null}return t=n.prototype,t.remove=function(e){var t=this.childNodes,n=this.firstChild,r=this.lastChild;if(this._=null,e&&2===t.length)r.parentNode.removeChild(r);else{var i=this.ownerDocument.createRange();i.setStartBefore(e?t[1]:n),i.setEndAfter(r),i.deleteContents()}return n},t.valueOf=function(e){var t=this._,n=null==t;if(n&&(t=this._=this.ownerDocument.createDocumentFragment()),n||e)for(var r=this.childNodes,i=0,o=r.length;i index.clean" + "sed 's/({})/(document)/' |", + "sed -e 's/var isNoOp =.*/var isNoOp = false;/' > index.clean" ], "mv index.clean index.js" ] @@ -146,7 +147,7 @@ "@ungap/essential-map": "^0.1.7", "@ungap/essential-weakset": "^0.1.2", "@ungap/is-array": "^0.1.1", - "@ungap/template-literal": "^0.1.0", + "@ungap/template-tag-arguments": "^0.1.1", "@ungap/weakmap": "^0.1.4", "disconnected": "^0.1.6", "domdiff": "^2.0.2", diff --git a/umd.js b/umd.js index 264a4ce4..c4743d6e 100644 --- a/umd.js +++ b/umd.js @@ -1,5 +1,6 @@ (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(X).replace(le,o).replace(ce,r)}function r(e,t,n,r){return"<"+t+n.replace(se,i)+r}function i(e,t,n){return t+(n||'"')+U+(n||'"')}function o(e,t,n){return re.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 g=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},O=function(e,t,n,r,i,o,a){var u,c,l,s,f,h,d,v=n+o,p=[];e:for(u=0;u<=v;u++){if(u>50)return null;for(d=u-1,f=u?p[u-1]:[0,0],h=p[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[i+s-1],e[t+l-1]);)m[g--]=0,s--,l--;if(!u)break;d=u-1,f=u?p[u-1]:[0,0],c=s-l,c===-u||c!==u&&f[d+c-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),K=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")==U)})(e.createElement("template"))||(U="_dt: "+U.slice(1,-1)+";");var X="\x3c!--"+U+"--\x3e",Y=8,ee=1,te=3,ne=/^(?:style|textarea)$/i,re=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,ie=" \\f\\n\\r\\t",oe="[ "+ie+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ae="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",ue="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",ce=new RegExp(ae+oe+ue+"+)([ "+ie+"]*/?>)","g"),le=new RegExp(ae+oe+ue+"*)([ "+ie+"]*/>)","g"),se=new RegExp("("+oe+"\\s*=\\s*)(['\"]?)"+X+"\\2","gi"),fe=new w,he=new w,de=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)}}(),ve="ownerSVGElement",pe=function(e,t){function n(t){var n=this.childNodes=e.call(t,0);this.firstChild=n[0],this.lastChild=n[n.length-1],this.ownerDocument=n[0].ownerDocument,this._=null}return t=n.prototype,t.remove=function(e){var t=this.childNodes,n=this.firstChild,r=this.lastChild;if(this._=null,e&&2===t.length)r.parentNode.removeChild(r);else{var i=this.ownerDocument.createRange();i.setStartBefore(e?t[1]:n),i.setEndAfter(r),i.deleteContents()}return n},t.valueOf=function(e){var t=this._,n=null==t;if(n&&(t=this._=this.ownerDocument.createDocumentFragment()),n||e)for(var r=this.childNodes,i=0,o=r.length;i"}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 g=Array(l),b=s[c];for(--n;b;){for(var w=b,y=w.newi,N=w.oldi;n>y;)g[--l]=1,--n;for(;a>N;)g[--l]=-1,--a;g[--l]=0,--n,--a,b=b.prev}for(;n>=t;)g[--l]=1,--n;for(;a>=o;)g[--l]=-1,--a;return g},L=function(e,t,n,r,i,o,a){var u,c,l,s,f,h,d,v=n+o,p=[];e:for(u=0;u<=v;u++){if(u>50)return null;for(d=u-1,f=u?p[u-1]:[0,0],h=p[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[i+s-1],e[t+l-1]);)m[g--]=0,s--,l--;if(!u)break;d=u-1,f=u?p[u-1]:[0,0],c=s-l,c===-u||c!==u&&f[d+c-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,t,n,r,i){var o="importNode"in e,a=e.createDocumentFragment();return a.appendChild(e.createTextNode("g")),a.appendChild(e.createTextNode("")),(o?e.importNode(a,!0):a.cloneNode(!0)).childNodes.length<2?function u(e,t){for(var n=e.cloneNode(),r=e.childNodes||[],i=r.length,o=0;t&&o

',e.content.childNodes[0].getAttribute("tabindex")==X)})(e.createElement("template"))||(X="_dt: "+X.slice(1,-1)+";");var Y="\x3c!--"+X+"--\x3e",ee=8,te=1,ne=3,re=/^(?:style|textarea)$/i,ie=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,oe=" \\f\\n\\r\\t",ae="[ "+oe+"]+[^ \\f\\n\\r\\t\\/>\"'=]+",ue="<([A-Za-z]+[A-Za-z0-9:_-]*)((?:",ce="(?:\\s*=\\s*(?:'[^']*?'|\"[^\"]*?\"|<[^>]*?>|[^ \\f\\n\\r\\t\\/>\"'=]+))?)",le=new RegExp(ue+ae+ce+"+)([ "+oe+"]*/?>)","g"),se=new RegExp(ue+ae+ce+"*)([ "+oe+"]*/>)","g"),fe=new RegExp("("+ae+"\\s*=\\s*)(['\"]?)"+Y+"\\2","gi"),he=new y,de=new y,ve=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)}}(),pe="ownerSVGElement",me=function(e,t){function n(t){var n=this.childNodes=e.call(t,0);this.firstChild=n[0],this.lastChild=n[n.length-1],this.ownerDocument=n[0].ownerDocument,this._=null}return t=n.prototype,t.remove=function(e){var t=this.childNodes,n=this.firstChild,r=this.lastChild;if(this._=null,e&&2===t.length)r.parentNode.removeChild(r);else{var i=this.ownerDocument.createRange();i.setStartBefore(e?t[1]:n),i.setEndAfter(r),i.deleteContents()}return n},t.valueOf=function(e){var t=this._,n=null==t;if(n&&(t=this._=this.ownerDocument.createDocumentFragment()),n||e)for(var r=this.childNodes,i=0,o=r.length;i