all files / hyperHTML/ min.js

82.88% Statements 92/111
64.23% Branches 88/137
82.35% Functions 28/34
100% Lines 2/2
1 2 28×
var hyperHTML=function(){"use strict";/*! (C) 2017 Andrea Giammarchi @WebReflection (MIT) */
function e(e){return C in this&&this[C].s===e?y.apply(this,arguments):b.apply(this,arguments)}function t(e,t){for(var n,r=k?T:x,i=E.call(e.attributes),c=0,a=i.length;c<a;c++)n=i[c],n.value===r&&t.push(o(e,k?e.getAttributeNode(N.shift()):n))}function n(e,o){for(var a,l,u=E.call(e.childNodes),s=u.length,h=0;h<s;h++)switch(a=u[h],a.nodeType){case 1:t(a,o),n(a,o);break;case 8:a.textContent===T&&(1===s?(o.push(r(e)),e.removeChild(a)):!(h<1||1===u[h-1].nodeType)||h+1!==s&&1!==u[h+1].nodeType?(l=e.ownerDocument.createTextNode(""),o.push(c(l)),e.replaceChild(l,a)):o.push(i(a)));break;case 3:"STYLE"===e.nodeName&&a.textContent===x&&o.push(c(e))}}function r(e){return function t(n){switch(typeof n){case"string":e.innerHTML=n;break;case"number":case"boolean":e.textContent=n;break;default:if(Array.isArray(n))Iif(1===n.length)t(n[0]);else Iif("string"==typeof n[0])t(n.join(""));else{var r=l(e.childNodes,n);-1<r&&p(e,n,r)}else s(e,n)}}}function o(e,t){var n,r=t.name,o="on"===r.slice(0,2),i=r in e&&!w.test(r);return i&&e.removeAttribute(r),i?function(t){n!==t&&(n=t,e[r]=o&&"handleEvent"in t?t.handleEvent.bind(t):t)}:function(e){n!==e&&(t.value=n=e)}}function i(e){var t=document.createDocumentFragment(),n=[];return function r(o){var i,c=e.parentNode;switch(typeof o){case"string":case"number":case"boolean":h(n,0),u(t,o),n=E.call(t.childNodes),c.insertBefore(t,e);break;default:Array.isArray(o)?0===o.length?r(o[0]):"string"==typeof o[0]?r(o.join("")):-1<(i=l(n,o))&&(h(n,i),o=o.slice(i),a(t,o),c.insertBefore(t,e),n.push.apply(n,o)):(h(n,0),n=11===o.nodeType?E.call(o.childNodes):[o],c.insertBefore(o,e))}}}function c(e){var t;return function(n){t!==n&&(e.textContent=t=n)}}function a(e,t){for(var n=0,r=t.length;n<r;n++)e.appendChild(t[n])}function l(e,t){Iif(e===t)return-1;for(var n=0,r=e.length,o=t.length;n<r;){if(!(n<o&&e[n]===t[n]))return n;n++}return n===o?-1:n}function u(e,t){var n=k&&/^[^\S]*?<(t(?:head|body|foot|r|d|h))/i.test(t),r=e.ownerDocument.createElement("template");r.innerHTML=n?"<table>"+t+"</table>":t,n&&(r={childNodes:r.querySelectorAll(RegExp.$1)}),a(e,E.call((r.content||r).childNodes))}function s(e,t){switch(t.nodeType){case 1:var n=e.childNodes;if(0<n.length&&n[0]===t){h(n,1);break}d(e,t);break;case 11:-1<l(e.childNodes,t.childNodes)&&d(e,t);break;case 3:e.textContent=t.textContent}}function h(e,t){for(var n,r=e.length;t<r--;)n=e[r],n.parentNode.removeChild(n)}function d(e,t){e.textContent="",e.appendChild(t)}function f(e){for(var t,n=[],r=e.childNodes,o=0,i=r.length;o<i;o++)t=r[o],(1===t.nodeType||0<D.call(t.textContent).length)&&n.push(t);return i=n.length,i<2?(t=i<1?e:n[0],function(){return t}):function(){return n}}function p(e,t,n){var r=e.ownerDocument.createDocumentFragment();0<n?(h(e.childNodes,n),a(r,t.slice(n)),e.appendChild(r)):(a(r,t),d(e,r))}function g(t){var n,r,o,i,c,l;return function(u){return l!==u&&(c=!0,l=u,o=document.createDocumentFragment(),r="svg"===t?document.createElementNS("http://www.w3.org/2000/svg","svg"):o,i=e.bind(r)),i.apply(null,arguments),c&&(c=!1,"svg"===t&&a(o,E.call(r.childNodes)),n=f(o)),n()}}function m(e,t,n){return e[t]||(e[t]=g(n))}function v(e,t){var n=L.get(e)||(L.set(e,n={}),n),r=t.indexOf(":");return r<0?m(n,t,t):m(n,t.slice(r+1),t.slice(0,r)||"html")}function y(){for(var e=1,t=arguments.length,n=this[C].u;e<t;e++)n[e-1](arguments[e]);return this}function b(e){var t=[],r=e.join(x);return k?(N=[],u(this,r.replace(M,A))):1===this.nodeType?this.innerHTML=r:u(this,r),n(this,t),this[C]={s:e,u:t},y.apply(this,arguments)}e.wire=function(e,t){return arguments.length<1?g("html"):null==e?g(t||"html"):v(e,t||"html")};var N,w=/^style$/i,C="_hyper_html: ",T=C+(Math.random()*new Date|0)+";",x="<!--"+T+"-->",k="documentMode"in document,M=k&&new RegExp("([^\\S][a-z]+[a-z0-9_-]*=)(['\"])"+x+"\\2","g"),A=k&&function(e,t,n){return N.push(t.slice(1,-1)),t+n+T+n},D=C.trim||function(){return this.replace(/^\s+|\s+$/g,"")},E=[].slice,L=typeof WeakMap==typeof L?{get:function(e){return e[C]},set:function(e,t){Object.defineProperty(e,C,{configurable:!0,value:t})}}:new WeakMap;return e}();try{module.exports=hyperHTML}catch(e){}