UNPKG

@purtuga/dom-data-bind

Version:

DOM Data Bind utility. Bind data to DOM

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