1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2024-11-22 07:49:38 +01:00
deka-dom-el/dist/esm.js

2 lines
9.4 KiB
JavaScript
Raw Normal View History

2024-01-31 14:41:18 +01:00
var A={isObservable(t){return!1},processReactiveAttribute(t,e,n,r){return n}};function z(t,e=!0){return e?Object.assign(A,t):(Object.setPrototypeOf(t,A),t)}function _(t){return A.isPrototypeOf(t)&&t!==A?t:A}function E(t){return typeof t>"u"}function O(t,e){if(!t||!(t instanceof AbortSignal))return!0;if(!t.aborted)return t.addEventListener("abort",e),function(){t.removeEventListener("abort",e)}}function k(t,e){let{observedAttributes:n=[]}=t.constructor;return n.reduce(function(r,o){return Reflect.set(r,B(o),e(t,o)),r},{})}function B(t){return t.replace(/-./g,e=>e[1].toUpperCase())}var a={setDeleteAttr:I,ssr:"",D:globalThis.document,F:globalThis.DocumentFragment,H:globalThis.HTMLElement,S:globalThis.SVGElement,M:globalThis.MutationObserver};function I(t,e,n){if(Reflect.set(t,e,n),!!E(n)){if(Reflect.deleteProperty(t,e),t instanceof a.H&&t.getAttribute(e)==="undefined")return t.removeAttribute(e);if(Reflect.get(t,e)==="undefined")return Reflect.set(t,e,"")}}var x="__dde_lifecycleToEvents";var v=[{get scope(){return a.D.body},host:t=>t?t(a.D.body):a.D.body,prevent:!0}],g={get current(){return v[v.length-1]},get host(){return this.current.host},preventDefault(){let{current:t}=this;return t.prevent=!0,t},get state(){return[...v]},push(t={}){return v.push(Object.assign({},this.current,{prevent:!1},t))},pushRoot(){return v.push(v[0])},pop(){if(v.length!==1)return v.pop()}};function W(...t){return this.appendOriginal(...t),this}function Z(t){return t.append===W||(t.appendOriginal=t.append,t.append=W),t}var S;function T(t,e,...n){let r=_(this),o=0,c,s;switch((Object(e)!==e||r.isObservable(e))&&(e={textContent:e}),!0){case typeof t=="function":{o=1,g.push({scope:t,host:(...l)=>l.length?(o===1?n.unshift(...l):l.forEach(p=>p(s)),void 0):s}),c=t(e||void 0);let d=c instanceof a.F;if(c.nodeName==="#comment")break;let h=T.mark({type:"component",name:t.name,host:d?"this":"parentElement"});c.prepend(h),d&&(s=h);break}case t==="#text":c=C.call(this,a.D.createTextNode(""),e);break;case(t==="<>"||!t):c=C.call(this,a.D.createDocumentFragment(),e);break;case!!S:c=C.call(this,a.D.createElementNS(S,t),e);break;case!c:c=C.call(this,a.D.createElement(t),e)}return Z(c),s||(s=c),n.forEach(d=>d(s)),o&&g.pop(),o=2,c}function ft(t,e=t,n=void 0){let r=Symbol.for("default"),o=Array.from(e.querySelectorAll("slot")).reduce((s,d)=>Reflect.set(s,d.name||r,d)&&s,{}),c=Reflect.has(o,r);if(t.append=new Proxy(t.append,{apply(s,d,h){if(!h.length)return t;let l=a.D.createDocumentFragment();for(let p of h){if(!p||!p.slot){c&&l.appendChild(p);continue}let y=p.slot,R=o[y];J(p,"remove","slot"),R&&(G(R,p,n),Reflect.deleteProperty(o,y))}return c&&(o[r].replaceWith(l),Reflect.deleteProperty(o,r)),t.append=s,t}}),t!==e){let s=Array.from(t.childNodes);s.forEach(d=>d.remove()),t.append(...s)}return e}function G(t,e,n){n&&n(t,e);try{t.replaceWith(C(e,{className:[e.className,t.className],dataset:{...t.dataset}}))}catch{t.replaceWith(e)}}T.mark=function(t,e=!1){t=Object.entries(t).map(([o,c])=>o+`="${c}"`).join(" ");let n=e?"":"/",r=a.D.createComment(`<dde:mark ${t}${a.ssr}${n}>`);return e&&(r.end=a.D.createComment("</dde:mark>")),r};function at(t){let e=this;return function(...r){S=t;let o=T.call(e,...r);return S=void 0,o}}var L=new WeakMap,{setDeleteAttr:j}=a;function C(t,...e){if(!e.length)return t;L.set(t,$(t,this));for(let[n,r]of Object.entries(Object.assign({},...e)))F.call(this,t,n,r);return L.delete(t),t}function F(t,e,n){let{setRemoveAttr:r,s:o}=$(t,this),c=this;n=o.processReactiveAttribute(t,e,n,(d,h)=>F.call(c,t,d,h));let[s]=e;if(s==="=")return r(e.slice(1),n);if(s===".")return q(t,e.slice(1),n);if(/(aria|data)([A-Z])/.test(e))return e=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r(e,n);switch(e==="className"&&(e="class"),e){case"xlink:href":return r(e,n,"http://www.w3.org/1999/xlink");case"textContent":return j(t,e,n);case"style":if(typeof n!="object")break;case"dataset":return N(o,n,q.bind(null,t[e]));case"ariaset":return N(o,n,(d,h)=>r("aria-"+d,h));case"classList":return V.call(c,t,n)}return K(t,e)?j(t,e,n):r(e,n)}function $(t,e){if(L.has(t))return L.get(t)