@purtuga/dom-data-bind
Version:
DOM Data Bind utility. Bind data to DOM
2 lines • 21.6 kB
JavaScript
!function(e,t,n,r,i,s,o,a,l,d,c,h,u,p,f,_,v,y,m,g,x,b,E,D,N){!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.DomDataBind=t():e.DomDataBind=t()}(e,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||d.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&d.defineProperty(e,Symbol.toStringTag,{value:"Module"}),d.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=d.create(null);if(n.r(r),d.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return d.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(t,n){t.exports=e.Map.Map=e.Map},function(t,n){t.exports=e.WeakMap.WeakMap=e.WeakMap},function(t,n){t.exports=e.Set.Set=e.Set},function(n,i,a){"use strict";a.r(i);var h={};a.r(h),a.d(h,"AttrDirective",function(){return it}),a.d(h,"ClassDirective",function(){return ct}),a.d(h,"EachDirective",function(){return yt}),a.d(h,"HtmlDirective",function(){return bt}),a.d(h,"IfDirective",function(){return Dt}),a.d(h,"OnDirective",function(){return At}),a.d(h,"PropDirective",function(){return $t}),a.d(h,"ShowDirective",function(){return It}),a.d(h,"StyleDirective",function(){return Pt});const u=c.bind.call.bind(c.bind),f=u(c.call.bind,c.call),_=f(d.prototype.toString),y=e=>"[object Object]"===_(e),m=e=>"[object String]"===_(e),g=e=>"[object Null]"===_(e),x=e=>"[object Undefined]"===_(e),b=(d.defineProperty,d.defineProperties,d.keys),E=[],w=l.isArray,C=f(E.forEach),T=(f(E.indexOf),f(E.splice)),k=f(E.slice),A=D.log,S=D.error||A;D.warn,"undefined"!=typeof Symbol&&Symbol.iterator&&Symbol.iterator;const $=HTMLElement.prototype,M=t,I=(M.head,e=>M.createElement(e)),B=e=>M.createTextNode(e||""),H=(f($.appendChild),f($.insertBefore),f($.hasAttribute)),P=f($.getAttribute),V=f($.setAttribute),L=f($.removeAttribute),K=e=>"[object DocumentFragment]"===_(e);var j=function e(t,...n){let r,i,s=t||{},o=n.length,a=!1;for("boolean"==typeof t&&(a=t,s=n.shift()||{},o=n.length),r=0;r<o;r++)if(n[r])for(i in n[r])n[r].hasOwnProperty(i)&&(a&&y(s[i])&&y(n[r][i])?s[i]=e(!0,s[i],n[r][i]):s[i]=n[r][i]);return s},W=a(1),O={stash:new W.WeakMap,create:function(){return new W.WeakMap}},G=a(2);const F=new(a.n(G).a);let R;var U=function(e){"function"==typeof e&&(F.add(e),R||(R=r(z,0)))};function z(){const e=[...F];let t;for(F.clear(),R=null;t=e.shift();)t(),t=null}const q=O.create(),J=["destroy","remove","off"];function Q(e){let t,n=[];for(t in e)n.push(t);return n}const X={isDestroyed:!1,init(){},destroy(e){if(q.has(this)){let t=q.get(this);q.delete(this),e?t.forEach(Z):U(()=>t.forEach(Z))}"boolean"==typeof this.isDestroyed&&(this.isDestroyed=!0)},onDestroy(e){(function(e){q.has(e)||q.set(e,[]);return q.get(e)})(this).push(e)},getFactory(){if(this.constructor)return this.constructor}},Y={extend:function(...e){let t=class extends(this){};return j(t.prototype,e.reduce(function(e,t){if(t){const n=t.prototype||t;Q(n).forEach(function(t){e[t]=n[t]})}return e},{})),t},isInstanceOf:function(e){return!!e&&!Q(this.prototype).some(function(t){return void 0===e[t]})},create:function(){return new this(...arguments)},getDestroyCallback:function(e,t){return()=>{e&&d.keys(e).forEach(function(t){e[t]&&(J.some(n=>{if(e[t][n]&&("remove"!==n||!(e[t]instanceof Node)))return e[t][n](),!0}),e[t]=N)}),t&&t.has&&t.has(e)&&t.delete(e)}}};function Z(e){"function"==typeof e&&e()}const ee=function(){function e(...t){return this&&this.constructor&&this instanceof this.constructor?this.init(...t):new e(...t)}return e.prototype.constructor=e,e}();j(ee.prototype,X),j(ee,Y);var te=ee,ne=a(0);const re=t,ie=c,se=Element.prototype,oe=new ne.Map;let ae=1;const le="DomDataBind",de=O.create(),ce=`D-${s.now()}-${p.random().toString(36).replace(/[^a-z0-9]+/g,"")}`,he=f,ue=y,pe=f(se.removeChild),fe=u(re.createComment,re),_e=function(e){const t=_(e);return"[object HTMLTemplateElement]"===t||"[object HTMLUnknownElement]"===t&&!!e.content},ve=S;function ye(e,t="runtime"){if(e=e.trim(),oe.has(e))return oe.get(e);const n=new ie("$DATA",`\nwith ($DATA) {\n if ($DATA.$data) {\n with ($DATA.$data) {\n return (${e});\n }\n } \n return (${e});\n}\n//# sourceURL=valueGetter:${t}.${ae++}.js`);return oe.set(e,n),n}function me(e){const t=[],n=e.attributes.length;for(let r=0;r<n;r++)t.push(e.attributes.item(r).name);return t}var ge=function(e,t){return l.prototype.slice.call(e.querySelectorAll(t))},xe=1,be=function(e,t){var n="000000000"+e;return n.substr(n.length-t)},Ee=function(){var t,n=0;for(t in e)n++;return n}(),De=be((navigator.mimeTypes.length+navigator.userAgent.length).toString(36)+Ee.toString(36),4),Ne=d.create({generate:function(){var e=(new s).getTime().toString(36),t=be((xe++).toString(36),4),n="xxxxxxxx".replace(/[x]/g,function(){return(16*p.random()|0).toString(16)});return"c"+e+t+De+n}});function we(e,t,n){return t in e?d.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ce(e,t){return t&&t.parentNode&&t.parentNode.insertBefore&&t.parentNode.insertBefore(e,t),e}function Te(e){return e&&e.parentNode&&e.parentNode.removeChild(e),e}class ke extends te{init(e,t,n){this._directives=n,this._d=this._directive=e,this._n=this._node=t}destroy(){const e=de.get(this);e&&(e.tracker&&e.tracker.stopWatchingAll&&e.tracker.stopWatchingAll(),e.data&&(e.data=null)),super.destroy(),de.delete(this)}render(e){this._d.render(this,this._n,e)}update(){}}class Ae extends te{static has(){return""}static manages(){return!1}render(e,t,n){let r=de.get(e);r||(r={data:null,value:"",isQueued:!1,tracker:()=>this.render(e,t,r.data)},de.set(e,r)),r.data!==n&&(r.tracker.stopWatchingAll&&r.tracker.stopWatchingAll(),r.data=n),this.update(e)}update(e){if(e.isDestroyed)return;const t=de.get(e);if(t){let n="";try{n=this._tokenValueGetter(t.data||{}),e.update&&e.update(n)}catch(e){ve(e)}t.value!==n&&(t.value=n)}}cleanNode(e){this._attr&&8!==e.nodeType&&L(e,this._attr)}getNodeHandler(e,t){return this.cleanNode(e),new this.constructor.NodeHandlerConstructor(this,e,t)}}we(Ae,"NodeHandlerConstructor",ke);var Se=Ae;const $e=new ne.Map;function Me(e,t=Me.directives||[]){const n=m(e)?e:e.innerHTML;return Ie(n)||$e.set(n,new qe(e,t)),$e.get(n)}function Ie(e){return $e.has(e)}Me.directives=null,Me.has=Ie;class Be{constructor(e,t,n=""){this._frag=e,this._bindings=t,this._childNodes=k(e.childNodes,0),this.fromTemplateId=n}recover(){this._childNodes.forEach(e=>this._frag.appendChild(e))}destroy(){if(this.recover(),this._bindings){for(let e=0,t=this._bindings.length;e<t;e++)this._bindings[e].destroy();this._bindings.length=0}}setData(e){for(let t=0,n=this._bindings.length;t<n;t++)this._bindings[t].render(e)}}function He(e,n,r){const i=e instanceof ze?e:Me(e,r),s=t.importNode(i.ele.content,!0);return s[le]=new Be(s,Qe(s,i._bindings,i._directives),i.id),s[le].setData(n),s}const Pe="text.binding",Ve=e=>!!e.parentNode;class Le extends Se{init(e){this._tokenText=e,this._tokenValueGetter=ye(e,Pe)}}we(Le,"NodeHandlerConstructor",class extends ke{init(...e){super.init(...e);let t=this._node;8===t.nodeType&&t.nodeValue===ce&&(this._placeholderEle=t,this._placeholderEle.data=Pe,this._node=Ce(B(""),this._placeholderEle),Te(this._placeholderEle)),this._placeholderEle||(this._placeholderEle=fe(Pe)),this._externalNodes=null,this._template=null,this._templateInst=null}update(e){if(g(e)||x(e))return this.clear(),void this.setPlaceholder();if(e instanceof ze){const t=de.get(this).data;return this._template&&this._template.id===e.id?void this._templateInst.DomDataBind.setData(t):(this.clear(),this.setPlaceholder(),this._template=e,this._templateInst=He(e,t,this._directives),void Ce(this._templateInst,this._placeholderEle))}if(e instanceof Node){if(this.isCurrentExternal(e))return;return this.clear(),this.setPlaceholder(),this.storeExternals(e),void Ce(e,this._placeholderEle)}Ve(this._node)||(this.clear(),Ce(this._node,this._placeholderEle),Te(this._placeholderEle)),e!==this._node.nodeValue&&(this._node.nodeValue=e)}storeExternals(e){this._externalNodes&&this.removeExternals(),this._externalNodes=K(e)?k(e.childNodes,0):[e]}removeExternals(){if(this._externalNodes){for(let e=0,t=this._externalNodes.length;e<t;e++)Te(this._externalNodes[e]);this._externalNodes=null}}isCurrentExternal(e){return this._externalNodes&&(!K(e)&&1===this._externalNodes.length&&this._externalNodes[0]===e||k(e).every((e,t)=>e===this._externalNodes[t]))}destroyTemplateView(){this._templateInst&&(this._templateInst.DomDataBind.destroy(),this._templateInst=this._template=null)}clear(){this.removeExternals(),this.destroyTemplateView(),this._node.nodeValue=""}setPlaceholder(){Ve(this._placeholderEle)||(Ce(this._placeholderEle,this._node),Te(this._node))}destroy(){super.destroy(),this.clear()}});var Ke=Le;const je=(()=>{const e=M.createDocumentFragment();return e.appendChild(B("test")),e.appendChild(B("")),1===e.cloneNode(!0).childNodes.length})(),We=(()=>{const e=I("div"),t=B("test");return e.appendChild(t),!e.contains(t)})(),Oe=he(Text.prototype.splitText),Ge=new RegExp("{{(.*?)}}"),Fe=new RegExp("{{(.*?)}}","g"),Re=e=>e?e.nodeValue:"",Ue=e=>Ge.test(Re(e));class ze{constructor(e,t=[]){this.id=Ne.generate(),_e(e)?this.ele=e:(this.ele=I("template"),this.ele.innerHTML=e),this._directives=t,this._bindings=Je(this.ele.content,t)}}var qe=ze;function Je(e,t){const n=new Map,r=new Map,i=new Set;let s;const o=e=>{let t,n,o,a=s;for(;t=e.has(s);)if(n=P(s,t),(o=e.manages())&&(a=fe("")),Xe(r,a).push(Ze(e,t,n)),L(s,t),o){i.add(s),s.parentNode.insertBefore(a,s);const e=I("div");e.appendChild(s),a.data=e.innerHTML}return o};return function(e){return[e].concat(ge(e,"*")).reduce(tt,[]).filter(et)}(e).forEach(e=>{let n=!1;if(i.size)for(let t of i.values())if(We&&3===e.nodeType?16&t.compareDocumentPosition(e)&&(n=!0):t.contains(e)&&(n=!0),n)break;s=e,n||(1===e.nodeType?t.some(o):3===e.nodeType&&(e=>{if(Ue(e)){Fe.lastIndex=0;let t=Re(e),n=Fe.exec(t);for(;n;)if(t==="{{"+n[1]+"}}")Xe(r,e).push(Ye(Ke,n[1])),n=null;else{let t=Oe(e,n.index);je&&nt(e),e=Oe(t,n[0].length);const i=t.parentNode.insertBefore(fe(ce),t);t.parentNode.removeChild(t),Xe(r,i).push(Ye(Ke,n[1])),Fe.lastIndex=0,!(n=Fe.exec(Re(e)))&&je&&nt(e)}}})(e))}),s=null,r.forEach((t,r)=>{if(e===r)return void n.set([],t);const i=[];let s=r,o=s.parentNode;for(;s!==e;)i.unshift(i.indexOf.call(o.childNodes,s)),o=(s=s.parentNode).parentNode;n.set(i,t)}),r.clear(),i.clear(),n}function Qe(e,t,n){const r=[];return t.forEach((t,i)=>{const s=function(e,t){if(!t.length)return e;return C(t,t=>e=e.childNodes[t]),e}(e,i);if(s)for(let e=0,i=t.length;e<i;e++)r.push(t[e].getNodeHandler(s,n));else ve(new v("dom-data-bind#render(): Unable to find node!"))}),r}function Xe(e,t){return e.has(t)||e.set(t,[]),e.get(t)}function Ye(e,t){t=t.trim();let n=de.get(e);return n||(n={},de.set(e,n)),n[t]||(n[t]=new e(t)),n[t]}function Ze(e,t,n){n=n.trim();const r=`${t}-${ce}-${n}`;let i=de.get(e);return i||(i={},de.set(e,i)),i[r]||(i[r]=new e(t,n)),i[r]}function et(e){return 1!==e.nodeType||1===e.nodeType&&e.attributes.length>0}function tt(e,t){if(e.push(t),t.hasChildNodes())for(t=t.firstChild;t;){const n=t.nextSibling;3===t.nodeType&&t.nodeValue&&Ge.test(Re(t))&&e.push(t),je&&nt(t),t=n}return e}function nt(e){3===e.nodeType&&je&&!e.nodeValue&&(e.parentNode.insertBefore(fe(""),e),e.parentNode.removeChild(e))}const rt=te.extend({$ele:null,init(e,t){const n=this.getFactory(),r={html:e,data:t,directives:n.directives.slice(0)};de.set(this,r),m(e)?(this.$ele=He(e,t,r.directives),r.bindings=this.$ele._bindings):(this.$ele=e,r.bindings=Qe(e,Je(e,r.directives),r.directives),t&&this.setData(t)),this.onDestroy(()=>{C(r.bindings,e=>e.destroy()),delete r.data,delete r.directives,delete r.bindings,n.getDestroyCallback(r,de)()})},setData(e){const t=de.get(this).bindings;C(t,t=>t.render(e))}});rt.directives=[];class it extends Se{static has(e){let t="";return me(e).some(e=>this._matches.test(e)&&(t=e)),t}init(e,t){this._attr=e,this._tokenValueGetter=ye(t||"","attr"),this._htmlAttr=new RegExp(this.constructor._matches).exec(e)[1]}}we(it,"NodeHandlerConstructor",class extends ke{update(e){const t=de.get(this),n=this._directive._htmlAttr;this._directive.constructor._isProp?e!==t.value&&(this._node[n]=e):e&&t.value!==e?V(this._node,n,e):t.value&&!e&&L(this._node,n)}}),we(it,"_matches",/^_attr\.(.*)/),we(it,"_isProp",!1);var st=it;var ot=function(e,t){return!(!e||!t)&&e.classList.contains(t)};var at=function(e,t){let n=o(t).trim().split(/\s+/).map(e=>e.trim());e&&n.length&&n.forEach(t=>e.classList.add(t))};var lt=function(e,t){return e.classList.remove(t)};const dt="_class";class ct extends Se{static has(e){return H(e,dt)?dt:""}init(e,t){this._attr=e,this._tokenValueGetter=ye(t||"","class")}}we(ct,"NodeHandlerConstructor",class extends ke{update(e){const{_node:t}=this,n=de.get(this).value||{};d.keys(e).concat(d.keys(n)).forEach(n=>{e[n]&&!ot(t,n)?at(t,n):!e[n]&&ot(t,n)&<(t,n)})}});const ht=Symbol("directive.each.setup"),ut="_each",pt="_key",ft=e=>e&&e._destroy(),_t=e=>e,vt=e=>w(e)&&!e.length||ue(e)&&!b(e).length;class yt extends Se{static has(e){return H(e,ut)?ut:""}static manages(){return!0}init(e,t){const[n,r]=function(e){let t=/\(?(.+?)\)?\W?(?:of|in)\W(.*)/.exec(e);if(t)return(t=t.slice(1))[0]=t[0].split(/,/).map(e=>o(e).trim()),t;return[]}((t||"").trim());this._attr=e,this._iteratorArgs=n,this._tokenValueGetter=ye(r||"","each")}destroyChildBinders(e,t){if(e&&e.length)if(e=e.splice(0),t._isSoleChild){const n=t._placeholderEle.parentNode;n.textContent="",n.appendChild(t._placeholderEle),r(()=>{C(e,e=>e._destroy())})}else C(e,e=>e._destroy())}getDataForIteration(e,t){return this._iteratorArgs.reduce((t,n)=>(t[n]=e.shift(),t),t||{})}iterateOverList(e,t){const n=de.get(e);let r,i=w(t);if(i)i=!0,r=t;else{if(!ue(t))return;r=b(t)}const s=e.binders,o=new ne.Map,a=r.length,{usesKey:l,getKey:d}=e._viewTemplate[ht];for(let c=0;c<a;c++){let a={$root:n.data.$root||n.data,$parent:n.data,$data:n.data.$data||n.data};i?this.getDataForIteration([r[c],c],a):this.getDataForIteration([t[r[c]],r[c],c],a);const h=d(l?a:i?r[c]:t[r[c]]);if(s[c]&&s[c]._loop.rowKey===h){s[c][le].setData(a);continue}s[c]&&(s[c][le].recover(),o.set(s[c]._loop.rowKey,s[c]),s[c]=null);let u=e.bindersByKey.get(h);if(u?null!==u._loop.pos&&s[u._loop.pos]===u&&(s[u._loop.pos]=null):(u=o.get(h))&&o.delete(h),u)s[c]=u,u._loop.pos=c,s[c][le].recover(),mt(s,c,e._placeholderEle),s[c][le].setData(a);else{if(o.size){const[e,t]=o.entries().next().value;(u=t)[le].setData(a),o.delete(e),u._loop.rowKey=h,u._loop.pos=c}else(u=He(e._viewTemplate,a,e._directives))._destroy=gt,u._handler=e,u._loop={rowKey:h,pos:c};s[c]=u,e.bindersByKey.set(h,u),mt(s,c,e._placeholderEle)}}o.size&&(C(o.values(),ft),o.clear()),a<s.length&&C(T(s,a),ft)}}function mt(e,t,n){const r=e[t];r[le].recover(),e[t+1]?Ce(r,e[t+1][le]._childNodes[0]):Ce(r,n)}function gt(){this[le].recover(),this._loop.rowKey&&this._handler.bindersByKey.delete(this._loop.rowKey),this[le].destroy()}we(yt,"NodeHandlerConstructor",class extends ke{constructor(...e){super(...e),we(this,"binders",[]),we(this,"bindersByKey",new ne.Map),we(this,"listIterator",()=>this._directive.iterateOverList(this,de.get(this).value))}init(e,t,n){super.init(e,t,n),this._placeholderEle=fe("directive.each"),this._isSoleChild=function(e){return l.prototype.every.call(e.parentNode.childNodes,t=>t===e||3===t.nodeType&&!t.textContent.trim())}(this._node),this._viewTemplate=Me(t.data,n),this._viewTemplate[ht]||function(e){if(!e[ht]){e[ht]={usesKey:!1,getKey:_t};const t=e.ele.content.firstChild;t&&t.hasAttribute&&H(t,pt)&&(e[ht].usesKey=!0,e[ht].getKey=ye(P(t,pt),"each.key"),L(t,pt))}}(this._viewTemplate),Ce(this._placeholderEle,t),pe(t.parentNode,t)}update(e){const t=de.get(this);e!==t.value&&(t.value=null,this.listIterator.stopWatchingAll&&this.listIterator.stopWatchingAll()),e?(t.value=e,vt(e)&&this.binders?this._directive.destroyChildBinders(this.binders,this):this.listIterator()):this._directive.destroyChildBinders(this.binders,this)}destroy(){this.listIterator.stopWatchingAll&&this.listIterator.stopWatchingAll(),this.bindersByKey.clear(),this._directive.destroyChildBinders(this.binders,this),super.destroy()}});const xt="_html";class bt extends Se{static has(e){return H(e,xt)?xt:""}init(e,t){this._attr=e,this._tokenValueGetter=ye(t||"","html")}}we(bt,"NodeHandlerConstructor",class extends ke{update(e){e!==de.get(this).value&&(this._node.innerHTML=e)}});const Et="_if";class Dt extends Se{static has(e){return H(e,Et)?Et:""}static manages(){return!0}init(e,t){this._attr=e,this._tokenValueGetter=ye(t||"","if")}}we(Dt,"NodeHandlerConstructor",class extends ke{constructor(...e){super(...e),we(this,"_renderedEle",null),we(this,"_renderTemplate",this._node.data)}init(...e){super.init(...e),this._placeholderEle=fe("directive.if"),Ce(this._placeholderEle,this._node),pe(this._node.parentNode,this._node)}update(e){const t=de.get(this);t.value!==e?e&&!this._renderedEle?(this._renderedEle=He(this._renderTemplate,t.data,this._directives),Ce(this._renderedEle,this._placeholderEle)):e||this.teardown():this._renderedEle&&this._renderedEle[le].setData(t.data)}teardown(){this._renderedEle&&(this._renderedEle[le].recover(),this._renderedEle[le].destroy(),this._renderedEle=null)}destroy(){this.teardown(),super.destroy()}});var Nt=function(e,t,n,r){let i=t.split(/\s+/),s={};return i.forEach(t=>{e.addEventListener(t,n,r),s[t]={remove:()=>e.removeEventListener(t,n,r)}}),d.create({listeners:s,remove:function(){i.forEach(e=>s[e].remove())}})};const wt=new RegExp(`^${(e=>o(e).replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&"))("_on.")}(.*)`),Ct=/^\d+$/,Tt={13:"enter",27:"esc",9:"tab",46:"delete",32:"space",38:"up",40:"down",37:"left",39:"right"},kt=d.values(Tt);class At extends Se{static has(e){let t="";return me(e).some(e=>wt.test(e)&&(t=e)),t}init(e,t){this._attr=e,this._info=function(e){const t={value:"",hasModifiers:!0,modifiers:e.split(/\./)};return t.value=t.modifiers.shift(),t.hasModifiers=Boolean(t.modifiers.length),t.modifiers=t.modifiers.reduce((e,t)=>(e[t]=!0,e),{}),t}(new RegExp(wt).exec(e)[1]),this._eventName=this._info.value,this._tokenValueGetter=ye(t||"","on");const n=this._info.modifiers;this._filter=b(n).some(e=>-1!==kt.indexOf(e)||Ct.test(e))}render(e,t,n){let r=de.get(e);r||(r={data:{$data:{}},tracker:()=>this.render(e,t,r.data)},de.set(e,r)),n&&(n.$data?r.data=n:r.data.$data=n)}}we(At,"NodeHandlerConstructor",class extends ke{init(...e){super.init(...e),this.setup()}handleEvent(e){const{hasModifiers:t,modifiers:n}=this._directive._info,r=e.which;if(this._directive._filter&&e instanceof KeyboardEvent&&!n[r]&&!n[Tt[r]])return;const i=de.get(this);let s,o;i.data.$ev=e;try{s=this._directive._tokenValueGetter.call(this._node,i.data)}catch(e){return void ve(e)}return delete i.data.$ev,"function"==typeof s?o=s.call(this._node,e):s&&"function"===s.handleEvent&&(o=s.handleEvent(e)),t&&(n.once&&this.teardown(),n.stop&&e.stopPropagation(),n.prevent&&e.preventDefault()),o}setup(){this._evListener=Nt(this._node,this._directive._eventName,this)}teardown(){this._evListener&&(this._evListener.remove(),this._evListener=null)}destroy(){this.teardown(),super.destroy()}});const St=/^_prop\.(.*)/;class $t extends st{static get _matches(){return St}static _isProp(){return!0}}const Mt="_show";class It extends Se{static has(e){return H(e,Mt)?Mt:""}init(e,t){this._attr=e,this._tokenValueGetter=ye(t||"","show")}}we(It,"NodeHandlerConstructor",class extends ke{init(...e){super.init(...e),this._origDisplayStyle=this._node.style.display||""}update(e){const t=this._node.style;e?t.display=this._origDisplayStyle:"none"!==t.display&&(t.display="none")}});function Bt(e,t){e&&"object"==typeof t&&d.keys(t).forEach(function(n){e.style[n]=t[n]})}const Ht="_style";class Pt extends Se{static has(e){return H(e,Ht)?Ht:""}init(e,t){this._attr=e,this._tokenValueGetter=ye(t||"","style")}}we(Pt,"NodeHandlerConstructor",class extends ke{update(e){Bt(this._node,e)}});a.d(i,"DomDataBindAll",function(){return Vt}),a.d(i,"allDirectives",function(){return Lt}),a.d(i,"AttrDirective",function(){return it}),a.d(i,"ClassDirective",function(){return ct}),a.d(i,"EachDirective",function(){return yt}),a.d(i,"HtmlDirective",function(){return bt}),a.d(i,"IfDirective",function(){return Dt}),a.d(i,"OnDirective",function(){return At}),a.d(i,"PropDirective",function(){return $t}),a.d(i,"ShowDirective",function(){return It}),a.d(i,"StyleDirective",function(){return Pt}),a.d(i,"DomDataBind",function(){return rt}),a.d(i,"render",function(){return He}),a.d(i,"view",function(){return Me}),a.d(i,"directives",function(){return h}),a.d(i,"Directive",function(){return Ae});const Vt=rt.extend(),Lt=[yt,Dt];d.keys(h).forEach(e=>{-1===Lt.indexOf(h[e])&&Lt.push(h[e])}),Vt.directives=Lt;i.default=Vt}])})}(window,document,location,setTimeout,setInterval,Date,String,Number,Array,Object,Function,atob,btoa,Math,JSON,TypeError,Error,encodeURIComponent,decodeURIComponent,requestAnimationFrame,CustomEvent,clearInterval,clearTimeout,console);
//# sourceMappingURL=dom-data-bind.umd.min.js.map