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

2 lines
9.3 KiB
JavaScript
Raw Normal View History

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