From bc2398a00522df1b7b1128846ced8e1d94f69074 Mon Sep 17 00:00:00 2001 From: Jan Andrle Date: Mon, 10 Mar 2025 16:35:09 +0100 Subject: [PATCH] :bug: Node in enviroment --- dist/esm-with-signals.js | 5 +++-- dist/esm-with-signals.min.js | 4 ++-- dist/esm.js | 5 +++-- dist/esm.min.js | 2 +- dist/iife-with-signals.js | 5 +++-- dist/iife-with-signals.min.js | 6 +++--- dist/iife.js | 5 +++-- dist/iife.min.js | 2 +- jsdom.js | 3 +-- src/dom-common.js | 1 + src/events-observer.js | 4 ++-- 11 files changed, 23 insertions(+), 19 deletions(-) diff --git a/dist/esm-with-signals.js b/dist/esm-with-signals.js index 4f12834..19bddfa 100644 --- a/dist/esm-with-signals.js +++ b/dist/esm-with-signals.js @@ -91,6 +91,7 @@ var enviroment = { setDeleteAttr, ssr: "", D: globalThis.document, + N: globalThis.Node, F: globalThis.DocumentFragment, H: globalThis.HTMLElement, S: globalThis.SVGElement, @@ -231,9 +232,9 @@ function connectionsChangesObserverConstructor() { if (store.size > 30) await requestIdle(); const out = []; - if (!isInstance(element, Node)) return out; + if (!isInstance(element, enviroment.N)) return out; for (const el of store.keys()) { - if (el === element || !isInstance(el, Node)) continue; + if (el === element || !isInstance(el, enviroment.N)) continue; if (element.contains(el)) out.push(el); } diff --git a/dist/esm-with-signals.min.js b/dist/esm-with-signals.min.js index 00f0e24..6ec45b5 100644 --- a/dist/esm-with-signals.min.js +++ b/dist/esm-with-signals.min.js @@ -1,4 +1,4 @@ var B=(...t)=>Object.prototype.hasOwnProperty.call(...t);function O(t){return typeof t>"u"}function et(t){let e=typeof t;return e!=="object"?e:t===null?"null":Object.prototype.toString.call(t)}function S(t,e){return t instanceof e}function nt(t,e){return Object.prototype.isPrototypeOf.call(e,t)}function w(t=null,e={}){return Object.create(t,e)}function b(...t){return Object.assign(...t)}function J(t,e){if(!t||!S(t,AbortSignal))return!0;if(!t.aborted)return t.addEventListener("abort",e),function(){t.removeEventListener("abort",e)}}function rt(t,e){let{observedAttributes:n=[]}=t.constructor;return n.reduce(function(r,o){return r[vt(o)]=e(t,o),r},{})}function vt(t){return t.replace(/-./g,e=>e[1].toUpperCase())}var P=class extends Error{constructor(){super();let[e,...n]=this.stack.split(` -`),r=e.slice(e.indexOf("@"),e.indexOf(".js:")+4),o=r.includes("src/helpers.js")?"src/":r;this.stack=n.find(c=>!c.includes(o))||e}get compact(){let{stack:e}=this;return e.slice(0,e.indexOf("@")+1)+"\u2026"+e.slice(e.lastIndexOf("/"))}};var q={isSignal(t){return!1},processReactiveAttribute(t,e,n,r){return n}};function Z(t,e=!0){return e?b(q,t):(Object.setPrototypeOf(t,q),t)}function W(t){return nt(t,q)&&t!==q?t:q}var d={setDeleteAttr:bt,ssr:"",D:globalThis.document,F:globalThis.DocumentFragment,H:globalThis.HTMLElement,S:globalThis.SVGElement,M:globalThis.MutationObserver,q:t=>t||Promise.resolve()};function bt(t,e,n){if(Reflect.set(t,e,n),!!O(n)){if(Reflect.deleteProperty(t,e),S(t,d.H)&&t.getAttribute(e)==="undefined")return t.removeAttribute(e);if(Reflect.get(t,e)==="undefined")return Reflect.set(t,e,"")}}var N="__dde_lifecyclesToEvents",A="dde:connected",D="dde:disconnected",F="dde:attributeChanged";var R=d.M?xt():new Proxy({},{get(){return()=>{}}});function xt(){let t=new Map,e=!1,n=u=>function(a){for(let f of a)if(f.type==="childList"){if(h(f.addedNodes,!0)){u();continue}v(f.removedNodes,!0)&&u()}},r=new d.M(n(i));return{observe(u){let a=new d.M(n(()=>{}));return a.observe(u,{childList:!0,subtree:!0}),()=>a.disconnect()},onConnected(u,a){s();let f=c(u);f.connected.has(a)||(f.connected.add(a),f.length_c+=1)},offConnected(u,a){if(!t.has(u))return;let f=t.get(u);f.connected.has(a)&&(f.connected.delete(a),f.length_c-=1,o(u,f))},onDisconnected(u,a){s();let f=c(u);f.disconnected.has(a)||(f.disconnected.add(a),f.length_d+=1)},offDisconnected(u,a){if(!t.has(u))return;let f=t.get(u);f.disconnected.delete(a),f.length_d-=1,o(u,f)}};function o(u,a){a.length_c||a.length_d||(t.delete(u),i())}function c(u){if(t.has(u))return t.get(u);let a={connected:new WeakSet,length_c:0,disconnected:new WeakSet,length_d:0};return t.set(u,a),a}function s(){e||(e=!0,r.observe(d.D.body,{childList:!0,subtree:!0}))}function i(){!e||t.size||(e=!1,r.disconnect())}function p(){return new Promise(function(u){(requestIdleCallback||requestAnimationFrame)(u)})}async function E(u){t.size>30&&await p();let a=[];if(!S(u,Node))return a;for(let f of t.keys())f===u||!S(f,Node)||u.contains(f)&&a.push(f);return a}function h(u,a){let f=!1;for(let _ of u){if(a&&E(_).then(h),!t.has(_))continue;let M=t.get(_);M.length_c&&(_.dispatchEvent(new Event(A)),M.connected=new WeakSet,M.length_c=0,M.length_d||t.delete(_),f=!0)}return f}function v(u,a){let f=!1;for(let _ of u)a&&E(_).then(v),!(!t.has(_)||!t.get(_).length_d)&&((globalThis.queueMicrotask||setTimeout)(T(_)),f=!0);return f}function T(u){return()=>{u.isConnected||(u.dispatchEvent(new Event(D)),t.delete(u))}}}function Bt(t,e,n){return typeof e=="function"&&(n=e,e=null),e||(e={}),function(o,...c){n&&(c.unshift(o),o=typeof n=="function"?n():n);let s=c.length?new CustomEvent(t,b({detail:c[0]},e)):new Event(t,e);return o.dispatchEvent(s)}}function y(t,e,n){return function(o){return o.addEventListener(t,e,n),o}}var ot=t=>b({},typeof t=="object"?t:null,{once:!0});y.connected=function(t,e){return e=ot(e),function(r){return r.addEventListener(A,t,e),r[N]?r:r.isConnected?(r.dispatchEvent(new Event(A)),r):(J(e.signal,()=>R.offConnected(r,t))&&R.onConnected(r,t),r)}};y.disconnected=function(t,e){return e=ot(e),function(r){return r.addEventListener(D,t,e),r[N]||J(e.signal,()=>R.offDisconnected(r,t))&&R.onDisconnected(r,t),r}};function Xt(t){return d.q(t)}var C=[{get scope(){return d.D.body},host:t=>t?t(d.D.body):d.D.body,prevent:!0}],G=new WeakMap,x={get current(){return C[C.length-1]},get host(){return this.current.host},get signal(){let{host:t}=this;if(G.has(t))return G.get(t);let e=new AbortController;return G.set(t,e),t(y.disconnected(()=>e.abort())),e.signal},preventDefault(){let{current:t}=this;return t.prevent=!0,t},get state(){return[...C]},push(t={}){return C.push(b({},this.current,{prevent:!1},t))},pushRoot(){return C.push(C[0])},pop(){if(C.length!==1)return C.pop()}};function ct(...t){return this.appendOriginal(...t),this}function Et(t){return t.append===ct||(t.appendOriginal=t.append,t.append=ct),t}var $;function j(t,e,...n){let r=W(this),o=0,c,s;switch((Object(e)!==e||r.isSignal(e))&&(e={textContent:e}),!0){case typeof t=="function":{o=1;let i=(...h)=>h.length?(o===1?n.unshift(...h):h.forEach(v=>v(s)),void 0):s;x.push({scope:t,host:i}),c=t(e||void 0);let p=S(c,d.F);if(c.nodeName==="#comment")break;let E=j.mark({type:"component",name:t.name,host:p?"this":"parentElement"});c.prepend(E),p&&(s=E);break}case t==="#text":c=I.call(this,d.D.createTextNode(""),e);break;case(t==="<>"||!t):c=I.call(this,d.D.createDocumentFragment(),e);break;case!!$:c=I.call(this,d.D.createElementNS($,t),e);break;case!c:c=I.call(this,d.D.createElement(t),e)}return Et(c),s||(s=c),n.forEach(i=>i(s)),o&&x.pop(),o=2,c}j.mark=function(t,e=!1){t=Object.entries(t).map(([o,c])=>o+`="${c}"`).join(" ");let n=e?"":"/",r=d.D.createComment(``);return e&&(r.end=d.D.createComment("")),r};function Yt(t){let e=this;return function(...r){$=t;let o=j.call(e,...r);return $=void 0,o}}function te(t,e=t){let n="\xB9\u2070",r="\u2713",o=Object.fromEntries(Array.from(e.querySelectorAll("slot")).filter(c=>!c.name.endsWith(n)).map(c=>[c.name+=n,c]));if(t.append=new Proxy(t.append,{apply(c,s,i){if(i[0]===e)return c.apply(t,i);for(let p of i){let E=(p.slot||"")+n;try{St(p,"remove","slot")}catch{}let h=o[E];if(!h)return;h.name.startsWith(r)||(h.childNodes.forEach(v=>v.remove()),h.name=r+E),h.append(p)}return t.append=c,t}}),t!==e){let c=Array.from(t.childNodes);t.append(...c)}return e}var U=new WeakMap,{setDeleteAttr:st}=d;function I(t,...e){if(!e.length)return t;U.set(t,ft(t,this));for(let[n,r]of Object.entries(b({},...e)))ut.call(this,t,n,r);return U.delete(t),t}function ut(t,e,n){let{setRemoveAttr:r,s:o}=ft(t,this),c=this;n=o.processReactiveAttribute(t,e,n,(i,p)=>ut.call(c,t,i,p));let[s]=e;if(s==="=")return r(e.slice(1),n);if(s===".")return it(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 st(t,e,n);case"style":if(typeof n!="object")break;case"dataset":return V(o,e,t,n,it.bind(null,t[e]));case"ariaset":return V(o,e,t,n,(i,p)=>r("aria-"+i,p));case"classList":return _t.call(c,t,n)}return wt(t,e)?st(t,e,n):r(e,n)}function ft(t,e){if(U.has(t))return U.get(t);let r=(S(t,d.S)?At:yt).bind(null,t,"Attribute"),o=W(e);return{setRemoveAttr:r,s:o}}function _t(t,e){let n=W(this);return V(n,"classList",t,e,(r,o)=>t.classList.toggle(r,o===-1?void 0:!!o)),t}function St(t,e,n,r){return S(t,d.H)?t[e+"Attribute"](n,r):t[e+"AttributeNS"](null,n,r)}function wt(t,e){if(!(e in t))return!1;let n=at(t,e);return!O(n.set)}function at(t,e){if(t=Object.getPrototypeOf(t),!t)return{};let n=Object.getOwnPropertyDescriptor(t,e);return n||at(t,e)}function V(t,e,n,r,o){let c=String;if(!(typeof r!="object"||r===null))return Object.entries(r).forEach(function([i,p]){i&&(i=new c(i),i.target=e,p=t.processReactiveAttribute(n,i,p,o),o(i,p))})}function yt(t,e,n,r){return t[(O(r)?"remove":"set")+e](n,r)}function At(t,e,n,r,o=null){return t[(O(r)?"remove":"set")+e+"NS"](o,n,r)}function it(t,e,n){if(Reflect.set(t,e,n),!!O(n))return Reflect.deleteProperty(t,e)}function ce(t,e,n={}){let r=t.host||t;x.push({scope:r,host:(...s)=>s.length?s.forEach(i=>i(r)):r}),typeof n=="function"&&(n=n.call(r,r));let o=r[N];o||Ct(r);let c=e.call(r,n);return o||r.dispatchEvent(new Event(A)),t.nodeType===11&&typeof t.mode=="string"&&r.addEventListener(D,R.observe(t),{once:!0}),x.pop(),t.append(c)}function Ct(t){return K(t.prototype,"connectedCallback",function(e,n,r){e.apply(n,r),n.dispatchEvent(new Event(A))}),K(t.prototype,"disconnectedCallback",function(e,n,r){e.apply(n,r),(globalThis.queueMicrotask||setTimeout)(()=>!n.isConnected&&n.dispatchEvent(new Event(D)))}),K(t.prototype,"attributeChangedCallback",function(e,n,r){let[o,,c]=r;n.dispatchEvent(new CustomEvent(F,{detail:[o,c]})),e.apply(n,r)}),t.prototype[N]=!0,t}function K(t,e,n){t[e]=new Proxy(t[e]||(()=>{}),{apply:n})}var l="__dde_signal",Q=(()=>{let t=new Set,e=!1;function n(){e=!1;let r=t;t=new Set;for(let o of r){let c=o[l];c&&c.listeners.forEach(s=>s(c.value))}}return function(r){t.add(r),!e&&(e=!0,queueMicrotask(n))}})();var Y=w(null,{get:{value(){return lt(this)}},set:{value(...t){return mt(this,...t)}},toJSON:{value(){return lt(this)}},valueOf:{value(){return this[l]&&this[l].value}}}),Ot=w(Y,{set:{value(){}}});function z(t){return t&&t[l]}var H=[],m=new WeakMap;function g(t,e){if(typeof t!="function")return dt(!1,t,e);if(z(t))return t;let n=dt(!0);function r(){let[o,...c]=m.get(r);if(m.set(r,new Set([o])),H.push(r),mt(n,t()),H.pop(),!c.length)return;let s=m.get(r);for(let i of c)s.has(i)||k(i,r)}return m.set(n[l],r),m.set(r,new Set([n])),r(),n}g.action=function(t,e,...n){let r=t[l];if(!r)return;let{actions:o}=r;if(!o||!B(o,e))throw new Error(`Action "${e}" not defined. See ${l}.actions.`);if(o[e].apply(r,n),r.skip)return delete r.skip;Q(t)};g.on=function t(e,n,r={}){let{signal:o}=r;if(!(o&&o.aborted)){if(Array.isArray(e))return e.forEach(c=>t(c,n,r));tt(e,n),o&&o.addEventListener("abort",()=>k(e,n))}};g.symbols={onclear:Symbol.for("Signal.onclear")};g.clear=function(...t){for(let n of t){let r=n[l];r&&(delete n.toJSON,r.onclear.forEach(o=>o.call(r)),e(n,r),delete n[l])}function e(n,r){r.listeners.forEach(o=>{if(r.listeners.delete(o),!m.has(o))return;let c=m.get(o);c.delete(n),!(c.size>1)&&(n.clear(...c),m.delete(o))})}};var L="__dde_reactive";function Dt(t=w()){return(e,n)=>B(t,e)?t[e]:t[e]=n()}g.el=function(t,e){let n=j.mark({type:"reactive",source:new P().compact},!0),r=n.end,o=d.D.createDocumentFragment();o.append(n,r);let{current:c}=x,s=w(),i=p=>{if(!n.parentNode||!r.parentNode)return k(t,i);let E=Dt(s);s=w(),x.push(c);let h=e(p,function(a,f){return s[a]=E(a,f)});x.pop(),Array.isArray(h)||(h=[h]);let v=document.createComment("");h.push(v),n.after(...h);let T;for(;(T=v.nextSibling)&&T!==r;)T.remove();v.remove(),n.isConnected&&Rt(c.host())};return tt(t,i),ht(t,i,n,e),i(t.get()),c.host(y.disconnected(()=>s={})),o};function Rt(t){!t||!t[L]||(requestIdleCallback||setTimeout)(function(){t[L]=t[L].filter(([e,n])=>n.isConnected?!0:(k(...e),!1))})}var Lt={_set(t){this.value=t}};function kt(t){return function(e,n){let r=w(Y,{set:{value(...c){return e.setAttribute(n,...c)}}}),o=gt(r,e.getAttribute(n),Lt);return t[n]=o,o}}var X="__dde_attributes";g.observedAttributes=function(t){let e=t[X]={},n=rt(t,kt(e));return y(F,function({detail:o}){/*! This maps attributes to signals (`S.observedAttributes`). +`),r=e.slice(e.indexOf("@"),e.indexOf(".js:")+4),o=r.includes("src/helpers.js")?"src/":r;this.stack=n.find(c=>!c.includes(o))||e}get compact(){let{stack:e}=this;return e.slice(0,e.indexOf("@")+1)+"\u2026"+e.slice(e.lastIndexOf("/"))}};var q={isSignal(t){return!1},processReactiveAttribute(t,e,n,r){return n}};function Z(t,e=!0){return e?b(q,t):(Object.setPrototypeOf(t,q),t)}function W(t){return nt(t,q)&&t!==q?t:q}var d={setDeleteAttr:bt,ssr:"",D:globalThis.document,N:globalThis.Node,F:globalThis.DocumentFragment,H:globalThis.HTMLElement,S:globalThis.SVGElement,M:globalThis.MutationObserver,q:t=>t||Promise.resolve()};function bt(t,e,n){if(Reflect.set(t,e,n),!!O(n)){if(Reflect.deleteProperty(t,e),S(t,d.H)&&t.getAttribute(e)==="undefined")return t.removeAttribute(e);if(Reflect.get(t,e)==="undefined")return Reflect.set(t,e,"")}}var k="__dde_lifecyclesToEvents",A="dde:connected",D="dde:disconnected",F="dde:attributeChanged";var R=d.M?xt():new Proxy({},{get(){return()=>{}}});function xt(){let t=new Map,e=!1,n=u=>function(a){for(let f of a)if(f.type==="childList"){if(h(f.addedNodes,!0)){u();continue}v(f.removedNodes,!0)&&u()}},r=new d.M(n(i));return{observe(u){let a=new d.M(n(()=>{}));return a.observe(u,{childList:!0,subtree:!0}),()=>a.disconnect()},onConnected(u,a){s();let f=c(u);f.connected.has(a)||(f.connected.add(a),f.length_c+=1)},offConnected(u,a){if(!t.has(u))return;let f=t.get(u);f.connected.has(a)&&(f.connected.delete(a),f.length_c-=1,o(u,f))},onDisconnected(u,a){s();let f=c(u);f.disconnected.has(a)||(f.disconnected.add(a),f.length_d+=1)},offDisconnected(u,a){if(!t.has(u))return;let f=t.get(u);f.disconnected.delete(a),f.length_d-=1,o(u,f)}};function o(u,a){a.length_c||a.length_d||(t.delete(u),i())}function c(u){if(t.has(u))return t.get(u);let a={connected:new WeakSet,length_c:0,disconnected:new WeakSet,length_d:0};return t.set(u,a),a}function s(){e||(e=!0,r.observe(d.D.body,{childList:!0,subtree:!0}))}function i(){!e||t.size||(e=!1,r.disconnect())}function p(){return new Promise(function(u){(requestIdleCallback||requestAnimationFrame)(u)})}async function E(u){t.size>30&&await p();let a=[];if(!S(u,d.N))return a;for(let f of t.keys())f===u||!S(f,d.N)||u.contains(f)&&a.push(f);return a}function h(u,a){let f=!1;for(let _ of u){if(a&&E(_).then(h),!t.has(_))continue;let M=t.get(_);M.length_c&&(_.dispatchEvent(new Event(A)),M.connected=new WeakSet,M.length_c=0,M.length_d||t.delete(_),f=!0)}return f}function v(u,a){let f=!1;for(let _ of u)a&&E(_).then(v),!(!t.has(_)||!t.get(_).length_d)&&((globalThis.queueMicrotask||setTimeout)(T(_)),f=!0);return f}function T(u){return()=>{u.isConnected||(u.dispatchEvent(new Event(D)),t.delete(u))}}}function Bt(t,e,n){return typeof e=="function"&&(n=e,e=null),e||(e={}),function(o,...c){n&&(c.unshift(o),o=typeof n=="function"?n():n);let s=c.length?new CustomEvent(t,b({detail:c[0]},e)):new Event(t,e);return o.dispatchEvent(s)}}function y(t,e,n){return function(o){return o.addEventListener(t,e,n),o}}var ot=t=>b({},typeof t=="object"?t:null,{once:!0});y.connected=function(t,e){return e=ot(e),function(r){return r.addEventListener(A,t,e),r[k]?r:r.isConnected?(r.dispatchEvent(new Event(A)),r):(J(e.signal,()=>R.offConnected(r,t))&&R.onConnected(r,t),r)}};y.disconnected=function(t,e){return e=ot(e),function(r){return r.addEventListener(D,t,e),r[k]||J(e.signal,()=>R.offDisconnected(r,t))&&R.onDisconnected(r,t),r}};function Xt(t){return d.q(t)}var C=[{get scope(){return d.D.body},host:t=>t?t(d.D.body):d.D.body,prevent:!0}],G=new WeakMap,x={get current(){return C[C.length-1]},get host(){return this.current.host},get signal(){let{host:t}=this;if(G.has(t))return G.get(t);let e=new AbortController;return G.set(t,e),t(y.disconnected(()=>e.abort())),e.signal},preventDefault(){let{current:t}=this;return t.prevent=!0,t},get state(){return[...C]},push(t={}){return C.push(b({},this.current,{prevent:!1},t))},pushRoot(){return C.push(C[0])},pop(){if(C.length!==1)return C.pop()}};function ct(...t){return this.appendOriginal(...t),this}function Et(t){return t.append===ct||(t.appendOriginal=t.append,t.append=ct),t}var $;function j(t,e,...n){let r=W(this),o=0,c,s;switch((Object(e)!==e||r.isSignal(e))&&(e={textContent:e}),!0){case typeof t=="function":{o=1;let i=(...h)=>h.length?(o===1?n.unshift(...h):h.forEach(v=>v(s)),void 0):s;x.push({scope:t,host:i}),c=t(e||void 0);let p=S(c,d.F);if(c.nodeName==="#comment")break;let E=j.mark({type:"component",name:t.name,host:p?"this":"parentElement"});c.prepend(E),p&&(s=E);break}case t==="#text":c=I.call(this,d.D.createTextNode(""),e);break;case(t==="<>"||!t):c=I.call(this,d.D.createDocumentFragment(),e);break;case!!$:c=I.call(this,d.D.createElementNS($,t),e);break;case!c:c=I.call(this,d.D.createElement(t),e)}return Et(c),s||(s=c),n.forEach(i=>i(s)),o&&x.pop(),o=2,c}j.mark=function(t,e=!1){t=Object.entries(t).map(([o,c])=>o+`="${c}"`).join(" ");let n=e?"":"/",r=d.D.createComment(``);return e&&(r.end=d.D.createComment("")),r};function Yt(t){let e=this;return function(...r){$=t;let o=j.call(e,...r);return $=void 0,o}}function te(t,e=t){let n="\xB9\u2070",r="\u2713",o=Object.fromEntries(Array.from(e.querySelectorAll("slot")).filter(c=>!c.name.endsWith(n)).map(c=>[c.name+=n,c]));if(t.append=new Proxy(t.append,{apply(c,s,i){if(i[0]===e)return c.apply(t,i);for(let p of i){let E=(p.slot||"")+n;try{St(p,"remove","slot")}catch{}let h=o[E];if(!h)return;h.name.startsWith(r)||(h.childNodes.forEach(v=>v.remove()),h.name=r+E),h.append(p)}return t.append=c,t}}),t!==e){let c=Array.from(t.childNodes);t.append(...c)}return e}var U=new WeakMap,{setDeleteAttr:st}=d;function I(t,...e){if(!e.length)return t;U.set(t,ft(t,this));for(let[n,r]of Object.entries(b({},...e)))ut.call(this,t,n,r);return U.delete(t),t}function ut(t,e,n){let{setRemoveAttr:r,s:o}=ft(t,this),c=this;n=o.processReactiveAttribute(t,e,n,(i,p)=>ut.call(c,t,i,p));let[s]=e;if(s==="=")return r(e.slice(1),n);if(s===".")return it(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 st(t,e,n);case"style":if(typeof n!="object")break;case"dataset":return V(o,e,t,n,it.bind(null,t[e]));case"ariaset":return V(o,e,t,n,(i,p)=>r("aria-"+i,p));case"classList":return _t.call(c,t,n)}return wt(t,e)?st(t,e,n):r(e,n)}function ft(t,e){if(U.has(t))return U.get(t);let r=(S(t,d.S)?At:yt).bind(null,t,"Attribute"),o=W(e);return{setRemoveAttr:r,s:o}}function _t(t,e){let n=W(this);return V(n,"classList",t,e,(r,o)=>t.classList.toggle(r,o===-1?void 0:!!o)),t}function St(t,e,n,r){return S(t,d.H)?t[e+"Attribute"](n,r):t[e+"AttributeNS"](null,n,r)}function wt(t,e){if(!(e in t))return!1;let n=at(t,e);return!O(n.set)}function at(t,e){if(t=Object.getPrototypeOf(t),!t)return{};let n=Object.getOwnPropertyDescriptor(t,e);return n||at(t,e)}function V(t,e,n,r,o){let c=String;if(!(typeof r!="object"||r===null))return Object.entries(r).forEach(function([i,p]){i&&(i=new c(i),i.target=e,p=t.processReactiveAttribute(n,i,p,o),o(i,p))})}function yt(t,e,n,r){return t[(O(r)?"remove":"set")+e](n,r)}function At(t,e,n,r,o=null){return t[(O(r)?"remove":"set")+e+"NS"](o,n,r)}function it(t,e,n){if(Reflect.set(t,e,n),!!O(n))return Reflect.deleteProperty(t,e)}function ce(t,e,n={}){let r=t.host||t;x.push({scope:r,host:(...s)=>s.length?s.forEach(i=>i(r)):r}),typeof n=="function"&&(n=n.call(r,r));let o=r[k];o||Ct(r);let c=e.call(r,n);return o||r.dispatchEvent(new Event(A)),t.nodeType===11&&typeof t.mode=="string"&&r.addEventListener(D,R.observe(t),{once:!0}),x.pop(),t.append(c)}function Ct(t){return K(t.prototype,"connectedCallback",function(e,n,r){e.apply(n,r),n.dispatchEvent(new Event(A))}),K(t.prototype,"disconnectedCallback",function(e,n,r){e.apply(n,r),(globalThis.queueMicrotask||setTimeout)(()=>!n.isConnected&&n.dispatchEvent(new Event(D)))}),K(t.prototype,"attributeChangedCallback",function(e,n,r){let[o,,c]=r;n.dispatchEvent(new CustomEvent(F,{detail:[o,c]})),e.apply(n,r)}),t.prototype[k]=!0,t}function K(t,e,n){t[e]=new Proxy(t[e]||(()=>{}),{apply:n})}var l="__dde_signal",Q=(()=>{let t=new Set,e=!1;function n(){e=!1;let r=t;t=new Set;for(let o of r){let c=o[l];c&&c.listeners.forEach(s=>s(c.value))}}return function(r){t.add(r),!e&&(e=!0,queueMicrotask(n))}})();var Y=w(null,{get:{value(){return lt(this)}},set:{value(...t){return mt(this,...t)}},toJSON:{value(){return lt(this)}},valueOf:{value(){return this[l]&&this[l].value}}}),Ot=w(Y,{set:{value(){}}});function z(t){return t&&t[l]}var H=[],m=new WeakMap;function g(t,e){if(typeof t!="function")return dt(!1,t,e);if(z(t))return t;let n=dt(!0);function r(){let[o,...c]=m.get(r);if(m.set(r,new Set([o])),H.push(r),mt(n,t()),H.pop(),!c.length)return;let s=m.get(r);for(let i of c)s.has(i)||N(i,r)}return m.set(n[l],r),m.set(r,new Set([n])),r(),n}g.action=function(t,e,...n){let r=t[l];if(!r)return;let{actions:o}=r;if(!o||!B(o,e))throw new Error(`Action "${e}" not defined. See ${l}.actions.`);if(o[e].apply(r,n),r.skip)return delete r.skip;Q(t)};g.on=function t(e,n,r={}){let{signal:o}=r;if(!(o&&o.aborted)){if(Array.isArray(e))return e.forEach(c=>t(c,n,r));tt(e,n),o&&o.addEventListener("abort",()=>N(e,n))}};g.symbols={onclear:Symbol.for("Signal.onclear")};g.clear=function(...t){for(let n of t){let r=n[l];r&&(delete n.toJSON,r.onclear.forEach(o=>o.call(r)),e(n,r),delete n[l])}function e(n,r){r.listeners.forEach(o=>{if(r.listeners.delete(o),!m.has(o))return;let c=m.get(o);c.delete(n),!(c.size>1)&&(n.clear(...c),m.delete(o))})}};var L="__dde_reactive";function Dt(t=w()){return(e,n)=>B(t,e)?t[e]:t[e]=n()}g.el=function(t,e){let n=j.mark({type:"reactive",source:new P().compact},!0),r=n.end,o=d.D.createDocumentFragment();o.append(n,r);let{current:c}=x,s=w(),i=p=>{if(!n.parentNode||!r.parentNode)return N(t,i);let E=Dt(s);s=w(),x.push(c);let h=e(p,function(a,f){return s[a]=E(a,f)});x.pop(),Array.isArray(h)||(h=[h]);let v=document.createComment("");h.push(v),n.after(...h);let T;for(;(T=v.nextSibling)&&T!==r;)T.remove();v.remove(),n.isConnected&&Rt(c.host())};return tt(t,i),ht(t,i,n,e),i(t.get()),c.host(y.disconnected(()=>s={})),o};function Rt(t){!t||!t[L]||(requestIdleCallback||setTimeout)(function(){t[L]=t[L].filter(([e,n])=>n.isConnected?!0:(N(...e),!1))})}var Lt={_set(t){this.value=t}};function Nt(t){return function(e,n){let r=w(Y,{set:{value(...c){return e.setAttribute(n,...c)}}}),o=gt(r,e.getAttribute(n),Lt);return t[n]=o,o}}var X="__dde_attributes";g.observedAttributes=function(t){let e=t[X]={},n=rt(t,Nt(e));return y(F,function({detail:o}){/*! This maps attributes to signals (`S.observedAttributes`). Investigate `__dde_attributes` key of the element. */let[c,s]=o,i=this[X][c];if(i)return g.action(i,"_set",s)})(t),y.disconnected(function(){/*! This removes all signals mapped to attributes (`S.observedAttributes`). - Investigate `__dde_attributes` key of the element. */g.clear(...Object.values(this[X]))})(t),n};var pt={isSignal:z,processReactiveAttribute(t,e,n,r){if(!z(n))return n;let o=c=>{if(!t.isConnected)return k(n,o);r(e,c)};return tt(n,o),ht(n,o,t,e),n.get()}};function ht(t,e,...n){let{current:r}=x;r.host(function(o){if(o[L])return o[L].push([[t,e],...n]);o[L]=[],!r.prevent&&y.disconnected(()=>o[L].forEach(([[c,s]])=>k(c,s,c[l]&&c[l].host&&c[l].host()===o)))(o)})}var Nt=new FinalizationRegistry(function(t){g.clear({[l]:t})});function dt(t,e,n){let r=w(t?Ot:Y),o=gt(r,e,n,t);return Nt.register(o,o[l]),o}var Tt=b(w(),{stopPropagation(){this.skip=!0}});function gt(t,e,n,r=!1){let o=[];et(n)!=="[object Object]"&&(n={});let{onclear:c}=g.symbols;n[c]&&(o.push(n[c]),delete n[c]);let{host:s}=x;return Reflect.defineProperty(t,l,{value:b(w(Tt),{value:e,actions:n,onclear:o,host:s,listeners:new Set,defined:new P().stack,readonly:r}),enumerable:!1,writable:!1,configurable:!0}),t}function Mt(){return H[H.length-1]}function lt(t){if(!t[l])return;let{value:e,listeners:n}=t[l],r=Mt();return r&&n.add(r),m.has(r)&&m.get(r).add(t),e}function mt(t,e,n){let r=t[l];if(!(!r||!n&&r.value===e))return r.value=e,Q(t),e}function tt(t,e){if(t[l])return t[l].listeners.add(e)}function k(t,e,n){let r=t[l];if(!r)return;let{listeners:o}=r,c=o.delete(e);if(!c||!n||o.size)return c;g.clear(t);let s=m.get(r);if(!s)return c;let i=m.get(s);if(!i)return c;for(let p of i)k(p,s,!0);return c}Z(pt);export{g as S,I as assign,ut as assignAttribute,Et as chainableAppend,_t as classListDeclarative,j as createElement,Yt as createElementNS,ce as customElementRender,Ct as customElementWithDDE,Bt as dispatchEvent,j as el,Yt as elNS,St as elementAttribute,z as isSignal,Ct as lifecyclesToEvents,y as on,Xt as queue,Z as registerReactivity,x as scope,g as signal,te as simulateSlots}; + Investigate `__dde_attributes` key of the element. */g.clear(...Object.values(this[X]))})(t),n};var pt={isSignal:z,processReactiveAttribute(t,e,n,r){if(!z(n))return n;let o=c=>{if(!t.isConnected)return N(n,o);r(e,c)};return tt(n,o),ht(n,o,t,e),n.get()}};function ht(t,e,...n){let{current:r}=x;r.host(function(o){if(o[L])return o[L].push([[t,e],...n]);o[L]=[],!r.prevent&&y.disconnected(()=>o[L].forEach(([[c,s]])=>N(c,s,c[l]&&c[l].host&&c[l].host()===o)))(o)})}var kt=new FinalizationRegistry(function(t){g.clear({[l]:t})});function dt(t,e,n){let r=w(t?Ot:Y),o=gt(r,e,n,t);return kt.register(o,o[l]),o}var Tt=b(w(),{stopPropagation(){this.skip=!0}});function gt(t,e,n,r=!1){let o=[];et(n)!=="[object Object]"&&(n={});let{onclear:c}=g.symbols;n[c]&&(o.push(n[c]),delete n[c]);let{host:s}=x;return Reflect.defineProperty(t,l,{value:b(w(Tt),{value:e,actions:n,onclear:o,host:s,listeners:new Set,defined:new P().stack,readonly:r}),enumerable:!1,writable:!1,configurable:!0}),t}function Mt(){return H[H.length-1]}function lt(t){if(!t[l])return;let{value:e,listeners:n}=t[l],r=Mt();return r&&n.add(r),m.has(r)&&m.get(r).add(t),e}function mt(t,e,n){let r=t[l];if(!(!r||!n&&r.value===e))return r.value=e,Q(t),e}function tt(t,e){if(t[l])return t[l].listeners.add(e)}function N(t,e,n){let r=t[l];if(!r)return;let{listeners:o}=r,c=o.delete(e);if(!c||!n||o.size)return c;g.clear(t);let s=m.get(r);if(!s)return c;let i=m.get(s);if(!i)return c;for(let p of i)N(p,s,!0);return c}Z(pt);export{g as S,I as assign,ut as assignAttribute,Et as chainableAppend,_t as classListDeclarative,j as createElement,Yt as createElementNS,ce as customElementRender,Ct as customElementWithDDE,Bt as dispatchEvent,j as el,Yt as elNS,St as elementAttribute,z as isSignal,Ct as lifecyclesToEvents,y as on,Xt as queue,Z as registerReactivity,x as scope,g as signal,te as simulateSlots}; diff --git a/dist/esm.js b/dist/esm.js index df77eb0..515d770 100644 --- a/dist/esm.js +++ b/dist/esm.js @@ -58,6 +58,7 @@ var enviroment = { setDeleteAttr, ssr: "", D: globalThis.document, + N: globalThis.Node, F: globalThis.DocumentFragment, H: globalThis.HTMLElement, S: globalThis.SVGElement, @@ -198,9 +199,9 @@ function connectionsChangesObserverConstructor() { if (store.size > 30) await requestIdle(); const out = []; - if (!isInstance(element, Node)) return out; + if (!isInstance(element, enviroment.N)) return out; for (const el of store.keys()) { - if (el === element || !isInstance(el, Node)) continue; + if (el === element || !isInstance(el, enviroment.N)) continue; if (element.contains(el)) out.push(el); } diff --git a/dist/esm.min.js b/dist/esm.min.js index 889ab43..63bd756 100644 --- a/dist/esm.min.js +++ b/dist/esm.min.js @@ -1 +1 @@ -function w(t){return typeof t>"u"}function g(t,e){return t instanceof e}function W(t,e){return Object.prototype.isPrototypeOf.call(e,t)}function v(...t){return Object.assign(...t)}function P(t,e){if(!t||!g(t,AbortSignal))return!0;if(!t.aborted)return t.addEventListener("abort",e),function(){t.removeEventListener("abort",e)}}var A={isSignal(t){return!1},processReactiveAttribute(t,e,n,r){return n}};function V(t,e=!0){return e?v(A,t):(Object.setPrototypeOf(t,A),t)}function S(t){return W(t,A)&&t!==A?t:A}var a={setDeleteAttr:J,ssr:"",D:globalThis.document,F:globalThis.DocumentFragment,H:globalThis.HTMLElement,S:globalThis.SVGElement,M:globalThis.MutationObserver,q:t=>t||Promise.resolve()};function J(t,e,n){if(Reflect.set(t,e,n),!!w(n)){if(Reflect.deleteProperty(t,e),g(t,a.H)&&t.getAttribute(e)==="undefined")return t.removeAttribute(e);if(Reflect.get(t,e)==="undefined")return Reflect.set(t,e,"")}}var y="__dde_lifecyclesToEvents",m="dde:connected",_="dde:disconnected",F="dde:attributeChanged";var O=a.M?K():new Proxy({},{get(){return()=>{}}});function K(){let t=new Map,e=!1,n=s=>function(u){for(let i of u)if(i.type==="childList"){if(l(i.addedNodes,!0)){s();continue}E(i.removedNodes,!0)&&s()}},r=new a.M(n(f));return{observe(s){let u=new a.M(n(()=>{}));return u.observe(s,{childList:!0,subtree:!0}),()=>u.disconnect()},onConnected(s,u){d();let i=c(s);i.connected.has(u)||(i.connected.add(u),i.length_c+=1)},offConnected(s,u){if(!t.has(s))return;let i=t.get(s);i.connected.has(u)&&(i.connected.delete(u),i.length_c-=1,o(s,i))},onDisconnected(s,u){d();let i=c(s);i.disconnected.has(u)||(i.disconnected.add(u),i.length_d+=1)},offDisconnected(s,u){if(!t.has(s))return;let i=t.get(s);i.disconnected.delete(u),i.length_d-=1,o(s,i)}};function o(s,u){u.length_c||u.length_d||(t.delete(s),f())}function c(s){if(t.has(s))return t.get(s);let u={connected:new WeakSet,length_c:0,disconnected:new WeakSet,length_d:0};return t.set(s,u),u}function d(){e||(e=!0,r.observe(a.D.body,{childList:!0,subtree:!0}))}function f(){!e||t.size||(e=!1,r.disconnect())}function p(){return new Promise(function(s){(requestIdleCallback||requestAnimationFrame)(s)})}async function b(s){t.size>30&&await p();let u=[];if(!g(s,Node))return u;for(let i of t.keys())i===s||!g(i,Node)||s.contains(i)&&u.push(i);return u}function l(s,u){let i=!1;for(let h of s){if(u&&b(h).then(l),!t.has(h))continue;let C=t.get(h);C.length_c&&(h.dispatchEvent(new Event(m)),C.connected=new WeakSet,C.length_c=0,C.length_d||t.delete(h),i=!0)}return i}function E(s,u){let i=!1;for(let h of s)u&&b(h).then(E),!(!t.has(h)||!t.get(h).length_d)&&((globalThis.queueMicrotask||setTimeout)(G(h)),i=!0);return i}function G(s){return()=>{s.isConnected||(s.dispatchEvent(new Event(_)),t.delete(s))}}}function ht(t,e,n){return typeof e=="function"&&(n=e,e=null),e||(e={}),function(o,...c){n&&(c.unshift(o),o=typeof n=="function"?n():n);let d=c.length?new CustomEvent(t,v({detail:c[0]},e)):new Event(t,e);return o.dispatchEvent(d)}}function L(t,e,n){return function(o){return o.addEventListener(t,e,n),o}}var I=t=>v({},typeof t=="object"?t:null,{once:!0});L.connected=function(t,e){return e=I(e),function(r){return r.addEventListener(m,t,e),r[y]?r:r.isConnected?(r.dispatchEvent(new Event(m)),r):(P(e.signal,()=>O.offConnected(r,t))&&O.onConnected(r,t),r)}};L.disconnected=function(t,e){return e=I(e),function(r){return r.addEventListener(_,t,e),r[y]||P(e.signal,()=>O.offDisconnected(r,t))&&O.onDisconnected(r,t),r}};function wt(t){return a.q(t)}var x=[{get scope(){return a.D.body},host:t=>t?t(a.D.body):a.D.body,prevent:!0}],M=new WeakMap,D={get current(){return x[x.length-1]},get host(){return this.current.host},get signal(){let{host:t}=this;if(M.has(t))return M.get(t);let e=new AbortController;return M.set(t,e),t(L.disconnected(()=>e.abort())),e.signal},preventDefault(){let{current:t}=this;return t.prevent=!0,t},get state(){return[...x]},push(t={}){return x.push(v({},this.current,{prevent:!1},t))},pushRoot(){return x.push(x[0])},pop(){if(x.length!==1)return x.pop()}};function $(...t){return this.appendOriginal(...t),this}function Q(t){return t.append===$||(t.appendOriginal=t.append,t.append=$),t}var T;function k(t,e,...n){let r=S(this),o=0,c,d;switch((Object(e)!==e||r.isSignal(e))&&(e={textContent:e}),!0){case typeof t=="function":{o=1;let f=(...l)=>l.length?(o===1?n.unshift(...l):l.forEach(E=>E(d)),void 0):d;D.push({scope:t,host:f}),c=t(e||void 0);let p=g(c,a.F);if(c.nodeName==="#comment")break;let b=k.mark({type:"component",name:t.name,host:p?"this":"parentElement"});c.prepend(b),p&&(d=b);break}case t==="#text":c=R.call(this,a.D.createTextNode(""),e);break;case(t==="<>"||!t):c=R.call(this,a.D.createDocumentFragment(),e);break;case!!T:c=R.call(this,a.D.createElementNS(T,t),e);break;case!c:c=R.call(this,a.D.createElement(t),e)}return Q(c),d||(d=c),n.forEach(f=>f(d)),o&&D.pop(),o=2,c}k.mark=function(t,e=!1){t=Object.entries(t).map(([o,c])=>o+`="${c}"`).join(" ");let n=e?"":"/",r=a.D.createComment(``);return e&&(r.end=a.D.createComment("")),r};function _t(t){let e=this;return function(...r){T=t;let o=k.call(e,...r);return T=void 0,o}}function Ot(t,e=t){let n="\xB9\u2070",r="\u2713",o=Object.fromEntries(Array.from(e.querySelectorAll("slot")).filter(c=>!c.name.endsWith(n)).map(c=>[c.name+=n,c]));if(t.append=new Proxy(t.append,{apply(c,d,f){if(f[0]===e)return c.apply(t,f);for(let p of f){let b=(p.slot||"")+n;try{Y(p,"remove","slot")}catch{}let l=o[b];if(!l)return;l.name.startsWith(r)||(l.childNodes.forEach(E=>E.remove()),l.name=r+b),l.append(p)}return t.append=c,t}}),t!==e){let c=Array.from(t.childNodes);t.append(...c)}return e}var N=new WeakMap,{setDeleteAttr:U}=a;function R(t,...e){if(!e.length)return t;N.set(t,B(t,this));for(let[n,r]of Object.entries(v({},...e)))z.call(this,t,n,r);return N.delete(t),t}function z(t,e,n){let{setRemoveAttr:r,s:o}=B(t,this),c=this;n=o.processReactiveAttribute(t,e,n,(f,p)=>z.call(c,t,f,p));let[d]=e;if(d==="=")return r(e.slice(1),n);if(d===".")return H(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 U(t,e,n);case"style":if(typeof n!="object")break;case"dataset":return j(o,e,t,n,H.bind(null,t[e]));case"ariaset":return j(o,e,t,n,(f,p)=>r("aria-"+f,p));case"classList":return X.call(c,t,n)}return tt(t,e)?U(t,e,n):r(e,n)}function B(t,e){if(N.has(t))return N.get(t);let r=(g(t,a.S)?nt:et).bind(null,t,"Attribute"),o=S(e);return{setRemoveAttr:r,s:o}}function X(t,e){let n=S(this);return j(n,"classList",t,e,(r,o)=>t.classList.toggle(r,o===-1?void 0:!!o)),t}function Y(t,e,n,r){return g(t,a.H)?t[e+"Attribute"](n,r):t[e+"AttributeNS"](null,n,r)}function tt(t,e){if(!(e in t))return!1;let n=Z(t,e);return!w(n.set)}function Z(t,e){if(t=Object.getPrototypeOf(t),!t)return{};let n=Object.getOwnPropertyDescriptor(t,e);return n||Z(t,e)}function j(t,e,n,r,o){let c=String;if(!(typeof r!="object"||r===null))return Object.entries(r).forEach(function([f,p]){f&&(f=new c(f),f.target=e,p=t.processReactiveAttribute(n,f,p,o),o(f,p))})}function et(t,e,n,r){return t[(w(r)?"remove":"set")+e](n,r)}function nt(t,e,n,r,o=null){return t[(w(r)?"remove":"set")+e+"NS"](o,n,r)}function H(t,e,n){if(Reflect.set(t,e,n),!!w(n))return Reflect.deleteProperty(t,e)}function St(t,e,n={}){let r=t.host||t;D.push({scope:r,host:(...d)=>d.length?d.forEach(f=>f(r)):r}),typeof n=="function"&&(n=n.call(r,r));let o=r[y];o||rt(r);let c=e.call(r,n);return o||r.dispatchEvent(new Event(m)),t.nodeType===11&&typeof t.mode=="string"&&r.addEventListener(_,O.observe(t),{once:!0}),D.pop(),t.append(c)}function rt(t){return q(t.prototype,"connectedCallback",function(e,n,r){e.apply(n,r),n.dispatchEvent(new Event(m))}),q(t.prototype,"disconnectedCallback",function(e,n,r){e.apply(n,r),(globalThis.queueMicrotask||setTimeout)(()=>!n.isConnected&&n.dispatchEvent(new Event(_)))}),q(t.prototype,"attributeChangedCallback",function(e,n,r){let[o,,c]=r;n.dispatchEvent(new CustomEvent(F,{detail:[o,c]})),e.apply(n,r)}),t.prototype[y]=!0,t}function q(t,e,n){t[e]=new Proxy(t[e]||(()=>{}),{apply:n})}export{R as assign,z as assignAttribute,Q as chainableAppend,X as classListDeclarative,k as createElement,_t as createElementNS,St as customElementRender,rt as customElementWithDDE,ht as dispatchEvent,k as el,_t as elNS,Y as elementAttribute,rt as lifecyclesToEvents,L as on,wt as queue,V as registerReactivity,D as scope,Ot as simulateSlots}; +function w(t){return typeof t>"u"}function g(t,e){return t instanceof e}function W(t,e){return Object.prototype.isPrototypeOf.call(e,t)}function v(...t){return Object.assign(...t)}function P(t,e){if(!t||!g(t,AbortSignal))return!0;if(!t.aborted)return t.addEventListener("abort",e),function(){t.removeEventListener("abort",e)}}var A={isSignal(t){return!1},processReactiveAttribute(t,e,n,r){return n}};function V(t,e=!0){return e?v(A,t):(Object.setPrototypeOf(t,A),t)}function S(t){return W(t,A)&&t!==A?t:A}var f={setDeleteAttr:J,ssr:"",D:globalThis.document,N:globalThis.Node,F:globalThis.DocumentFragment,H:globalThis.HTMLElement,S:globalThis.SVGElement,M:globalThis.MutationObserver,q:t=>t||Promise.resolve()};function J(t,e,n){if(Reflect.set(t,e,n),!!w(n)){if(Reflect.deleteProperty(t,e),g(t,f.H)&&t.getAttribute(e)==="undefined")return t.removeAttribute(e);if(Reflect.get(t,e)==="undefined")return Reflect.set(t,e,"")}}var y="__dde_lifecyclesToEvents",m="dde:connected",_="dde:disconnected",F="dde:attributeChanged";var O=f.M?K():new Proxy({},{get(){return()=>{}}});function K(){let t=new Map,e=!1,n=s=>function(u){for(let i of u)if(i.type==="childList"){if(l(i.addedNodes,!0)){s();continue}E(i.removedNodes,!0)&&s()}},r=new f.M(n(a));return{observe(s){let u=new f.M(n(()=>{}));return u.observe(s,{childList:!0,subtree:!0}),()=>u.disconnect()},onConnected(s,u){d();let i=c(s);i.connected.has(u)||(i.connected.add(u),i.length_c+=1)},offConnected(s,u){if(!t.has(s))return;let i=t.get(s);i.connected.has(u)&&(i.connected.delete(u),i.length_c-=1,o(s,i))},onDisconnected(s,u){d();let i=c(s);i.disconnected.has(u)||(i.disconnected.add(u),i.length_d+=1)},offDisconnected(s,u){if(!t.has(s))return;let i=t.get(s);i.disconnected.delete(u),i.length_d-=1,o(s,i)}};function o(s,u){u.length_c||u.length_d||(t.delete(s),a())}function c(s){if(t.has(s))return t.get(s);let u={connected:new WeakSet,length_c:0,disconnected:new WeakSet,length_d:0};return t.set(s,u),u}function d(){e||(e=!0,r.observe(f.D.body,{childList:!0,subtree:!0}))}function a(){!e||t.size||(e=!1,r.disconnect())}function p(){return new Promise(function(s){(requestIdleCallback||requestAnimationFrame)(s)})}async function b(s){t.size>30&&await p();let u=[];if(!g(s,f.N))return u;for(let i of t.keys())i===s||!g(i,f.N)||s.contains(i)&&u.push(i);return u}function l(s,u){let i=!1;for(let h of s){if(u&&b(h).then(l),!t.has(h))continue;let C=t.get(h);C.length_c&&(h.dispatchEvent(new Event(m)),C.connected=new WeakSet,C.length_c=0,C.length_d||t.delete(h),i=!0)}return i}function E(s,u){let i=!1;for(let h of s)u&&b(h).then(E),!(!t.has(h)||!t.get(h).length_d)&&((globalThis.queueMicrotask||setTimeout)(G(h)),i=!0);return i}function G(s){return()=>{s.isConnected||(s.dispatchEvent(new Event(_)),t.delete(s))}}}function ht(t,e,n){return typeof e=="function"&&(n=e,e=null),e||(e={}),function(o,...c){n&&(c.unshift(o),o=typeof n=="function"?n():n);let d=c.length?new CustomEvent(t,v({detail:c[0]},e)):new Event(t,e);return o.dispatchEvent(d)}}function L(t,e,n){return function(o){return o.addEventListener(t,e,n),o}}var I=t=>v({},typeof t=="object"?t:null,{once:!0});L.connected=function(t,e){return e=I(e),function(r){return r.addEventListener(m,t,e),r[y]?r:r.isConnected?(r.dispatchEvent(new Event(m)),r):(P(e.signal,()=>O.offConnected(r,t))&&O.onConnected(r,t),r)}};L.disconnected=function(t,e){return e=I(e),function(r){return r.addEventListener(_,t,e),r[y]||P(e.signal,()=>O.offDisconnected(r,t))&&O.onDisconnected(r,t),r}};function wt(t){return f.q(t)}var x=[{get scope(){return f.D.body},host:t=>t?t(f.D.body):f.D.body,prevent:!0}],M=new WeakMap,D={get current(){return x[x.length-1]},get host(){return this.current.host},get signal(){let{host:t}=this;if(M.has(t))return M.get(t);let e=new AbortController;return M.set(t,e),t(L.disconnected(()=>e.abort())),e.signal},preventDefault(){let{current:t}=this;return t.prevent=!0,t},get state(){return[...x]},push(t={}){return x.push(v({},this.current,{prevent:!1},t))},pushRoot(){return x.push(x[0])},pop(){if(x.length!==1)return x.pop()}};function $(...t){return this.appendOriginal(...t),this}function Q(t){return t.append===$||(t.appendOriginal=t.append,t.append=$),t}var T;function k(t,e,...n){let r=S(this),o=0,c,d;switch((Object(e)!==e||r.isSignal(e))&&(e={textContent:e}),!0){case typeof t=="function":{o=1;let a=(...l)=>l.length?(o===1?n.unshift(...l):l.forEach(E=>E(d)),void 0):d;D.push({scope:t,host:a}),c=t(e||void 0);let p=g(c,f.F);if(c.nodeName==="#comment")break;let b=k.mark({type:"component",name:t.name,host:p?"this":"parentElement"});c.prepend(b),p&&(d=b);break}case t==="#text":c=R.call(this,f.D.createTextNode(""),e);break;case(t==="<>"||!t):c=R.call(this,f.D.createDocumentFragment(),e);break;case!!T:c=R.call(this,f.D.createElementNS(T,t),e);break;case!c:c=R.call(this,f.D.createElement(t),e)}return Q(c),d||(d=c),n.forEach(a=>a(d)),o&&D.pop(),o=2,c}k.mark=function(t,e=!1){t=Object.entries(t).map(([o,c])=>o+`="${c}"`).join(" ");let n=e?"":"/",r=f.D.createComment(``);return e&&(r.end=f.D.createComment("")),r};function _t(t){let e=this;return function(...r){T=t;let o=k.call(e,...r);return T=void 0,o}}function Ot(t,e=t){let n="\xB9\u2070",r="\u2713",o=Object.fromEntries(Array.from(e.querySelectorAll("slot")).filter(c=>!c.name.endsWith(n)).map(c=>[c.name+=n,c]));if(t.append=new Proxy(t.append,{apply(c,d,a){if(a[0]===e)return c.apply(t,a);for(let p of a){let b=(p.slot||"")+n;try{Y(p,"remove","slot")}catch{}let l=o[b];if(!l)return;l.name.startsWith(r)||(l.childNodes.forEach(E=>E.remove()),l.name=r+b),l.append(p)}return t.append=c,t}}),t!==e){let c=Array.from(t.childNodes);t.append(...c)}return e}var N=new WeakMap,{setDeleteAttr:U}=f;function R(t,...e){if(!e.length)return t;N.set(t,B(t,this));for(let[n,r]of Object.entries(v({},...e)))z.call(this,t,n,r);return N.delete(t),t}function z(t,e,n){let{setRemoveAttr:r,s:o}=B(t,this),c=this;n=o.processReactiveAttribute(t,e,n,(a,p)=>z.call(c,t,a,p));let[d]=e;if(d==="=")return r(e.slice(1),n);if(d===".")return H(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 U(t,e,n);case"style":if(typeof n!="object")break;case"dataset":return j(o,e,t,n,H.bind(null,t[e]));case"ariaset":return j(o,e,t,n,(a,p)=>r("aria-"+a,p));case"classList":return X.call(c,t,n)}return tt(t,e)?U(t,e,n):r(e,n)}function B(t,e){if(N.has(t))return N.get(t);let r=(g(t,f.S)?nt:et).bind(null,t,"Attribute"),o=S(e);return{setRemoveAttr:r,s:o}}function X(t,e){let n=S(this);return j(n,"classList",t,e,(r,o)=>t.classList.toggle(r,o===-1?void 0:!!o)),t}function Y(t,e,n,r){return g(t,f.H)?t[e+"Attribute"](n,r):t[e+"AttributeNS"](null,n,r)}function tt(t,e){if(!(e in t))return!1;let n=Z(t,e);return!w(n.set)}function Z(t,e){if(t=Object.getPrototypeOf(t),!t)return{};let n=Object.getOwnPropertyDescriptor(t,e);return n||Z(t,e)}function j(t,e,n,r,o){let c=String;if(!(typeof r!="object"||r===null))return Object.entries(r).forEach(function([a,p]){a&&(a=new c(a),a.target=e,p=t.processReactiveAttribute(n,a,p,o),o(a,p))})}function et(t,e,n,r){return t[(w(r)?"remove":"set")+e](n,r)}function nt(t,e,n,r,o=null){return t[(w(r)?"remove":"set")+e+"NS"](o,n,r)}function H(t,e,n){if(Reflect.set(t,e,n),!!w(n))return Reflect.deleteProperty(t,e)}function St(t,e,n={}){let r=t.host||t;D.push({scope:r,host:(...d)=>d.length?d.forEach(a=>a(r)):r}),typeof n=="function"&&(n=n.call(r,r));let o=r[y];o||rt(r);let c=e.call(r,n);return o||r.dispatchEvent(new Event(m)),t.nodeType===11&&typeof t.mode=="string"&&r.addEventListener(_,O.observe(t),{once:!0}),D.pop(),t.append(c)}function rt(t){return q(t.prototype,"connectedCallback",function(e,n,r){e.apply(n,r),n.dispatchEvent(new Event(m))}),q(t.prototype,"disconnectedCallback",function(e,n,r){e.apply(n,r),(globalThis.queueMicrotask||setTimeout)(()=>!n.isConnected&&n.dispatchEvent(new Event(_)))}),q(t.prototype,"attributeChangedCallback",function(e,n,r){let[o,,c]=r;n.dispatchEvent(new CustomEvent(F,{detail:[o,c]})),e.apply(n,r)}),t.prototype[y]=!0,t}function q(t,e,n){t[e]=new Proxy(t[e]||(()=>{}),{apply:n})}export{R as assign,z as assignAttribute,Q as chainableAppend,X as classListDeclarative,k as createElement,_t as createElementNS,St as customElementRender,rt as customElementWithDDE,ht as dispatchEvent,k as el,_t as elNS,Y as elementAttribute,rt as lifecyclesToEvents,L as on,wt as queue,V as registerReactivity,D as scope,Ot as simulateSlots}; diff --git a/dist/iife-with-signals.js b/dist/iife-with-signals.js index 97552ee..f7b4781 100644 --- a/dist/iife-with-signals.js +++ b/dist/iife-with-signals.js @@ -136,6 +136,7 @@ var DDE = (() => { setDeleteAttr, ssr: "", D: globalThis.document, + N: globalThis.Node, F: globalThis.DocumentFragment, H: globalThis.HTMLElement, S: globalThis.SVGElement, @@ -276,9 +277,9 @@ var DDE = (() => { if (store.size > 30) await requestIdle(); const out = []; - if (!isInstance(element, Node)) return out; + if (!isInstance(element, enviroment.N)) return out; for (const el of store.keys()) { - if (el === element || !isInstance(el, Node)) continue; + if (el === element || !isInstance(el, enviroment.N)) continue; if (element.contains(el)) out.push(el); } diff --git a/dist/iife-with-signals.min.js b/dist/iife-with-signals.min.js index 422eb9b..57876ad 100644 --- a/dist/iife-with-signals.min.js +++ b/dist/iife-with-signals.min.js @@ -1,4 +1,4 @@ -var DDE=(()=>{var J=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var yt=Object.prototype.hasOwnProperty;var At=(t,e)=>{for(var n in e)J(t,n,{get:e[n],enumerable:!0})},Ct=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of wt(e))!yt.call(t,o)&&o!==n&&J(t,o,{get:()=>e[o],enumerable:!(r=St(e,o))||r.enumerable});return t};var Ot=t=>Ct(J({},"__esModule",{value:!0}),t);var Zt={};At(Zt,{S:()=>g,assign:()=>W,assignAttribute:()=>Q,chainableAppend:()=>at,classListDeclarative:()=>lt,createElement:()=>T,createElementNS:()=>Tt,customElementRender:()=>Wt,customElementWithDDE:()=>gt,dispatchEvent:()=>kt,el:()=>T,elNS:()=>Tt,elementAttribute:()=>pt,isSignal:()=>F,lifecyclesToEvents:()=>gt,on:()=>y,queue:()=>Nt,registerReactivity:()=>I,scope:()=>m,signal:()=>g,simulateSlots:()=>Mt});var Z=(...t)=>Object.prototype.hasOwnProperty.call(...t);function O(t){return typeof t>"u"}function rt(t){let e=typeof t;return e!=="object"?e:t===null?"null":Object.prototype.toString.call(t)}function S(t,e){return t instanceof e}function ot(t,e){return Object.prototype.isPrototypeOf.call(e,t)}function w(t=null,e={}){return Object.create(t,e)}function x(...t){return Object.assign(...t)}function G(t,e){if(!t||!S(t,AbortSignal))return!0;if(!t.aborted)return t.addEventListener("abort",e),function(){t.removeEventListener("abort",e)}}function ct(t,e){let{observedAttributes:n=[]}=t.constructor;return n.reduce(function(r,o){return r[Dt(o)]=e(t,o),r},{})}function Dt(t){return t.replace(/-./g,e=>e[1].toUpperCase())}var q=class extends Error{constructor(){super();let[e,...n]=this.stack.split(` -`),r=e.slice(e.indexOf("@"),e.indexOf(".js:")+4),o=r.includes("src/helpers.js")?"src/":r;this.stack=n.find(c=>!c.includes(o))||e}get compact(){let{stack:e}=this;return e.slice(0,e.indexOf("@")+1)+"\u2026"+e.slice(e.lastIndexOf("/"))}};var j={isSignal(t){return!1},processReactiveAttribute(t,e,n,r){return n}};function I(t,e=!0){return e?x(j,t):(Object.setPrototypeOf(t,j),t)}function $(t){return ot(t,j)&&t!==j?t:j}var d={setDeleteAttr:Rt,ssr:"",D:globalThis.document,F:globalThis.DocumentFragment,H:globalThis.HTMLElement,S:globalThis.SVGElement,M:globalThis.MutationObserver,q:t=>t||Promise.resolve()};function Rt(t,e,n){if(Reflect.set(t,e,n),!!O(n)){if(Reflect.deleteProperty(t,e),S(t,d.H)&&t.getAttribute(e)==="undefined")return t.removeAttribute(e);if(Reflect.get(t,e)==="undefined")return Reflect.set(t,e,"")}}var N="__dde_lifecyclesToEvents",A="dde:connected",D="dde:disconnected",U="dde:attributeChanged";var R=d.M?Lt():new Proxy({},{get(){return()=>{}}});function Lt(){let t=new Map,e=!1,n=u=>function(a){for(let f of a)if(f.type==="childList"){if(h(f.addedNodes,!0)){u();continue}b(f.removedNodes,!0)&&u()}},r=new d.M(n(i));return{observe(u){let a=new d.M(n(()=>{}));return a.observe(u,{childList:!0,subtree:!0}),()=>a.disconnect()},onConnected(u,a){s();let f=c(u);f.connected.has(a)||(f.connected.add(a),f.length_c+=1)},offConnected(u,a){if(!t.has(u))return;let f=t.get(u);f.connected.has(a)&&(f.connected.delete(a),f.length_c-=1,o(u,f))},onDisconnected(u,a){s();let f=c(u);f.disconnected.has(a)||(f.disconnected.add(a),f.length_d+=1)},offDisconnected(u,a){if(!t.has(u))return;let f=t.get(u);f.disconnected.delete(a),f.length_d-=1,o(u,f)}};function o(u,a){a.length_c||a.length_d||(t.delete(u),i())}function c(u){if(t.has(u))return t.get(u);let a={connected:new WeakSet,length_c:0,disconnected:new WeakSet,length_d:0};return t.set(u,a),a}function s(){e||(e=!0,r.observe(d.D.body,{childList:!0,subtree:!0}))}function i(){!e||t.size||(e=!1,r.disconnect())}function p(){return new Promise(function(u){(requestIdleCallback||requestAnimationFrame)(u)})}async function E(u){t.size>30&&await p();let a=[];if(!S(u,Node))return a;for(let f of t.keys())f===u||!S(f,Node)||u.contains(f)&&a.push(f);return a}function h(u,a){let f=!1;for(let _ of u){if(a&&E(_).then(h),!t.has(_))continue;let P=t.get(_);P.length_c&&(_.dispatchEvent(new Event(A)),P.connected=new WeakSet,P.length_c=0,P.length_d||t.delete(_),f=!0)}return f}function b(u,a){let f=!1;for(let _ of u)a&&E(_).then(b),!(!t.has(_)||!t.get(_).length_d)&&((globalThis.queueMicrotask||setTimeout)(M(_)),f=!0);return f}function M(u){return()=>{u.isConnected||(u.dispatchEvent(new Event(D)),t.delete(u))}}}function kt(t,e,n){return typeof e=="function"&&(n=e,e=null),e||(e={}),function(o,...c){n&&(c.unshift(o),o=typeof n=="function"?n():n);let s=c.length?new CustomEvent(t,x({detail:c[0]},e)):new Event(t,e);return o.dispatchEvent(s)}}function y(t,e,n){return function(o){return o.addEventListener(t,e,n),o}}var st=t=>x({},typeof t=="object"?t:null,{once:!0});y.connected=function(t,e){return e=st(e),function(r){return r.addEventListener(A,t,e),r[N]?r:r.isConnected?(r.dispatchEvent(new Event(A)),r):(G(e.signal,()=>R.offConnected(r,t))&&R.onConnected(r,t),r)}};y.disconnected=function(t,e){return e=st(e),function(r){return r.addEventListener(D,t,e),r[N]||G(e.signal,()=>R.offDisconnected(r,t))&&R.onDisconnected(r,t),r}};function Nt(t){return d.q(t)}var C=[{get scope(){return d.D.body},host:t=>t?t(d.D.body):d.D.body,prevent:!0}],V=new WeakMap,m={get current(){return C[C.length-1]},get host(){return this.current.host},get signal(){let{host:t}=this;if(V.has(t))return V.get(t);let e=new AbortController;return V.set(t,e),t(y.disconnected(()=>e.abort())),e.signal},preventDefault(){let{current:t}=this;return t.prevent=!0,t},get state(){return[...C]},push(t={}){return C.push(x({},this.current,{prevent:!1},t))},pushRoot(){return C.push(C[0])},pop(){if(C.length!==1)return C.pop()}};function it(...t){return this.appendOriginal(...t),this}function at(t){return t.append===it||(t.appendOriginal=t.append,t.append=it),t}var z;function T(t,e,...n){let r=$(this),o=0,c,s;switch((Object(e)!==e||r.isSignal(e))&&(e={textContent:e}),!0){case typeof t=="function":{o=1;let i=(...h)=>h.length?(o===1?n.unshift(...h):h.forEach(b=>b(s)),void 0):s;m.push({scope:t,host:i}),c=t(e||void 0);let p=S(c,d.F);if(c.nodeName==="#comment")break;let E=T.mark({type:"component",name:t.name,host:p?"this":"parentElement"});c.prepend(E),p&&(s=E);break}case t==="#text":c=W.call(this,d.D.createTextNode(""),e);break;case(t==="<>"||!t):c=W.call(this,d.D.createDocumentFragment(),e);break;case!!z:c=W.call(this,d.D.createElementNS(z,t),e);break;case!c:c=W.call(this,d.D.createElement(t),e)}return at(c),s||(s=c),n.forEach(i=>i(s)),o&&m.pop(),o=2,c}T.mark=function(t,e=!1){t=Object.entries(t).map(([o,c])=>o+`="${c}"`).join(" ");let n=e?"":"/",r=d.D.createComment(``);return e&&(r.end=d.D.createComment("")),r};function Tt(t){let e=this;return function(...r){z=t;let o=T.call(e,...r);return z=void 0,o}}function Mt(t,e=t){let n="\xB9\u2070",r="\u2713",o=Object.fromEntries(Array.from(e.querySelectorAll("slot")).filter(c=>!c.name.endsWith(n)).map(c=>[c.name+=n,c]));if(t.append=new Proxy(t.append,{apply(c,s,i){if(i[0]===e)return c.apply(t,i);for(let p of i){let E=(p.slot||"")+n;try{pt(p,"remove","slot")}catch{}let h=o[E];if(!h)return;h.name.startsWith(r)||(h.childNodes.forEach(b=>b.remove()),h.name=r+E),h.append(p)}return t.append=c,t}}),t!==e){let c=Array.from(t.childNodes);t.append(...c)}return e}var H=new WeakMap,{setDeleteAttr:ut}=d;function W(t,...e){if(!e.length)return t;H.set(t,dt(t,this));for(let[n,r]of Object.entries(x({},...e)))Q.call(this,t,n,r);return H.delete(t),t}function Q(t,e,n){let{setRemoveAttr:r,s:o}=dt(t,this),c=this;n=o.processReactiveAttribute(t,e,n,(i,p)=>Q.call(c,t,i,p));let[s]=e;if(s==="=")return r(e.slice(1),n);if(s===".")return ft(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 ut(t,e,n);case"style":if(typeof n!="object")break;case"dataset":return K(o,e,t,n,ft.bind(null,t[e]));case"ariaset":return K(o,e,t,n,(i,p)=>r("aria-"+i,p));case"classList":return lt.call(c,t,n)}return Pt(t,e)?ut(t,e,n):r(e,n)}function dt(t,e){if(H.has(t))return H.get(t);let r=(S(t,d.S)?jt:qt).bind(null,t,"Attribute"),o=$(e);return{setRemoveAttr:r,s:o}}function lt(t,e){let n=$(this);return K(n,"classList",t,e,(r,o)=>t.classList.toggle(r,o===-1?void 0:!!o)),t}function pt(t,e,n,r){return S(t,d.H)?t[e+"Attribute"](n,r):t[e+"AttributeNS"](null,n,r)}function Pt(t,e){if(!(e in t))return!1;let n=ht(t,e);return!O(n.set)}function ht(t,e){if(t=Object.getPrototypeOf(t),!t)return{};let n=Object.getOwnPropertyDescriptor(t,e);return n||ht(t,e)}function K(t,e,n,r,o){let c=String;if(!(typeof r!="object"||r===null))return Object.entries(r).forEach(function([i,p]){i&&(i=new c(i),i.target=e,p=t.processReactiveAttribute(n,i,p,o),o(i,p))})}function qt(t,e,n,r){return t[(O(r)?"remove":"set")+e](n,r)}function jt(t,e,n,r,o=null){return t[(O(r)?"remove":"set")+e+"NS"](o,n,r)}function ft(t,e,n){if(Reflect.set(t,e,n),!!O(n))return Reflect.deleteProperty(t,e)}function Wt(t,e,n={}){let r=t.host||t;m.push({scope:r,host:(...s)=>s.length?s.forEach(i=>i(r)):r}),typeof n=="function"&&(n=n.call(r,r));let o=r[N];o||gt(r);let c=e.call(r,n);return o||r.dispatchEvent(new Event(A)),t.nodeType===11&&typeof t.mode=="string"&&r.addEventListener(D,R.observe(t),{once:!0}),m.pop(),t.append(c)}function gt(t){return X(t.prototype,"connectedCallback",function(e,n,r){e.apply(n,r),n.dispatchEvent(new Event(A))}),X(t.prototype,"disconnectedCallback",function(e,n,r){e.apply(n,r),(globalThis.queueMicrotask||setTimeout)(()=>!n.isConnected&&n.dispatchEvent(new Event(D)))}),X(t.prototype,"attributeChangedCallback",function(e,n,r){let[o,,c]=r;n.dispatchEvent(new CustomEvent(U,{detail:[o,c]})),e.apply(n,r)}),t.prototype[N]=!0,t}function X(t,e,n){t[e]=new Proxy(t[e]||(()=>{}),{apply:n})}var l="__dde_signal",Y=(()=>{let t=new Set,e=!1;function n(){e=!1;let r=t;t=new Set;for(let o of r){let c=o[l];c&&c.listeners.forEach(s=>s(c.value))}}return function(r){t.add(r),!e&&(e=!0,queueMicrotask(n))}})();var et=w(null,{get:{value(){return vt(this)}},set:{value(...t){return _t(this,...t)}},toJSON:{value(){return vt(this)}},valueOf:{value(){return this[l]&&this[l].value}}}),Ft=w(et,{set:{value(){}}});function F(t){return t&&t[l]}var B=[],v=new WeakMap;function g(t,e){if(typeof t!="function")return mt(!1,t,e);if(F(t))return t;let n=mt(!0);function r(){let[o,...c]=v.get(r);if(v.set(r,new Set([o])),B.push(r),_t(n,t()),B.pop(),!c.length)return;let s=v.get(r);for(let i of c)s.has(i)||k(i,r)}return v.set(n[l],r),v.set(r,new Set([n])),r(),n}g.action=function(t,e,...n){let r=t[l];if(!r)return;let{actions:o}=r;if(!o||!Z(o,e))throw new Error(`Action "${e}" not defined. See ${l}.actions.`);if(o[e].apply(r,n),r.skip)return delete r.skip;Y(t)};g.on=function t(e,n,r={}){let{signal:o}=r;if(!(o&&o.aborted)){if(Array.isArray(e))return e.forEach(c=>t(c,n,r));nt(e,n),o&&o.addEventListener("abort",()=>k(e,n))}};g.symbols={onclear:Symbol.for("Signal.onclear")};g.clear=function(...t){for(let n of t){let r=n[l];r&&(delete n.toJSON,r.onclear.forEach(o=>o.call(r)),e(n,r),delete n[l])}function e(n,r){r.listeners.forEach(o=>{if(r.listeners.delete(o),!v.has(o))return;let c=v.get(o);c.delete(n),!(c.size>1)&&(n.clear(...c),v.delete(o))})}};var L="__dde_reactive";function It(t=w()){return(e,n)=>Z(t,e)?t[e]:t[e]=n()}g.el=function(t,e){let n=T.mark({type:"reactive",source:new q().compact},!0),r=n.end,o=d.D.createDocumentFragment();o.append(n,r);let{current:c}=m,s=w(),i=p=>{if(!n.parentNode||!r.parentNode)return k(t,i);let E=It(s);s=w(),m.push(c);let h=e(p,function(a,f){return s[a]=E(a,f)});m.pop(),Array.isArray(h)||(h=[h]);let b=document.createComment("");h.push(b),n.after(...h);let M;for(;(M=b.nextSibling)&&M!==r;)M.remove();b.remove(),n.isConnected&&$t(c.host())};return nt(t,i),xt(t,i,n,e),i(t.get()),c.host(y.disconnected(()=>s={})),o};function $t(t){!t||!t[L]||(requestIdleCallback||setTimeout)(function(){t[L]=t[L].filter(([e,n])=>n.isConnected?!0:(k(...e),!1))})}var Ut={_set(t){this.value=t}};function zt(t){return function(e,n){let r=w(et,{set:{value(...c){return e.setAttribute(n,...c)}}}),o=Et(r,e.getAttribute(n),Ut);return t[n]=o,o}}var tt="__dde_attributes";g.observedAttributes=function(t){let e=t[tt]={},n=ct(t,zt(e));return y(U,function({detail:o}){/*! This maps attributes to signals (`S.observedAttributes`). +var DDE=(()=>{var J=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var yt=Object.prototype.hasOwnProperty;var At=(t,e)=>{for(var n in e)J(t,n,{get:e[n],enumerable:!0})},Ct=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of wt(e))!yt.call(t,o)&&o!==n&&J(t,o,{get:()=>e[o],enumerable:!(r=St(e,o))||r.enumerable});return t};var Ot=t=>Ct(J({},"__esModule",{value:!0}),t);var Zt={};At(Zt,{S:()=>g,assign:()=>W,assignAttribute:()=>Q,chainableAppend:()=>at,classListDeclarative:()=>lt,createElement:()=>T,createElementNS:()=>Tt,customElementRender:()=>Wt,customElementWithDDE:()=>gt,dispatchEvent:()=>Nt,el:()=>T,elNS:()=>Tt,elementAttribute:()=>pt,isSignal:()=>F,lifecyclesToEvents:()=>gt,on:()=>y,queue:()=>kt,registerReactivity:()=>I,scope:()=>m,signal:()=>g,simulateSlots:()=>Mt});var Z=(...t)=>Object.prototype.hasOwnProperty.call(...t);function O(t){return typeof t>"u"}function rt(t){let e=typeof t;return e!=="object"?e:t===null?"null":Object.prototype.toString.call(t)}function S(t,e){return t instanceof e}function ot(t,e){return Object.prototype.isPrototypeOf.call(e,t)}function w(t=null,e={}){return Object.create(t,e)}function x(...t){return Object.assign(...t)}function G(t,e){if(!t||!S(t,AbortSignal))return!0;if(!t.aborted)return t.addEventListener("abort",e),function(){t.removeEventListener("abort",e)}}function ct(t,e){let{observedAttributes:n=[]}=t.constructor;return n.reduce(function(r,o){return r[Dt(o)]=e(t,o),r},{})}function Dt(t){return t.replace(/-./g,e=>e[1].toUpperCase())}var q=class extends Error{constructor(){super();let[e,...n]=this.stack.split(` +`),r=e.slice(e.indexOf("@"),e.indexOf(".js:")+4),o=r.includes("src/helpers.js")?"src/":r;this.stack=n.find(c=>!c.includes(o))||e}get compact(){let{stack:e}=this;return e.slice(0,e.indexOf("@")+1)+"\u2026"+e.slice(e.lastIndexOf("/"))}};var j={isSignal(t){return!1},processReactiveAttribute(t,e,n,r){return n}};function I(t,e=!0){return e?x(j,t):(Object.setPrototypeOf(t,j),t)}function $(t){return ot(t,j)&&t!==j?t:j}var d={setDeleteAttr:Rt,ssr:"",D:globalThis.document,N:globalThis.Node,F:globalThis.DocumentFragment,H:globalThis.HTMLElement,S:globalThis.SVGElement,M:globalThis.MutationObserver,q:t=>t||Promise.resolve()};function Rt(t,e,n){if(Reflect.set(t,e,n),!!O(n)){if(Reflect.deleteProperty(t,e),S(t,d.H)&&t.getAttribute(e)==="undefined")return t.removeAttribute(e);if(Reflect.get(t,e)==="undefined")return Reflect.set(t,e,"")}}var k="__dde_lifecyclesToEvents",A="dde:connected",D="dde:disconnected",U="dde:attributeChanged";var R=d.M?Lt():new Proxy({},{get(){return()=>{}}});function Lt(){let t=new Map,e=!1,n=u=>function(a){for(let f of a)if(f.type==="childList"){if(h(f.addedNodes,!0)){u();continue}b(f.removedNodes,!0)&&u()}},r=new d.M(n(i));return{observe(u){let a=new d.M(n(()=>{}));return a.observe(u,{childList:!0,subtree:!0}),()=>a.disconnect()},onConnected(u,a){s();let f=c(u);f.connected.has(a)||(f.connected.add(a),f.length_c+=1)},offConnected(u,a){if(!t.has(u))return;let f=t.get(u);f.connected.has(a)&&(f.connected.delete(a),f.length_c-=1,o(u,f))},onDisconnected(u,a){s();let f=c(u);f.disconnected.has(a)||(f.disconnected.add(a),f.length_d+=1)},offDisconnected(u,a){if(!t.has(u))return;let f=t.get(u);f.disconnected.delete(a),f.length_d-=1,o(u,f)}};function o(u,a){a.length_c||a.length_d||(t.delete(u),i())}function c(u){if(t.has(u))return t.get(u);let a={connected:new WeakSet,length_c:0,disconnected:new WeakSet,length_d:0};return t.set(u,a),a}function s(){e||(e=!0,r.observe(d.D.body,{childList:!0,subtree:!0}))}function i(){!e||t.size||(e=!1,r.disconnect())}function p(){return new Promise(function(u){(requestIdleCallback||requestAnimationFrame)(u)})}async function E(u){t.size>30&&await p();let a=[];if(!S(u,d.N))return a;for(let f of t.keys())f===u||!S(f,d.N)||u.contains(f)&&a.push(f);return a}function h(u,a){let f=!1;for(let _ of u){if(a&&E(_).then(h),!t.has(_))continue;let P=t.get(_);P.length_c&&(_.dispatchEvent(new Event(A)),P.connected=new WeakSet,P.length_c=0,P.length_d||t.delete(_),f=!0)}return f}function b(u,a){let f=!1;for(let _ of u)a&&E(_).then(b),!(!t.has(_)||!t.get(_).length_d)&&((globalThis.queueMicrotask||setTimeout)(M(_)),f=!0);return f}function M(u){return()=>{u.isConnected||(u.dispatchEvent(new Event(D)),t.delete(u))}}}function Nt(t,e,n){return typeof e=="function"&&(n=e,e=null),e||(e={}),function(o,...c){n&&(c.unshift(o),o=typeof n=="function"?n():n);let s=c.length?new CustomEvent(t,x({detail:c[0]},e)):new Event(t,e);return o.dispatchEvent(s)}}function y(t,e,n){return function(o){return o.addEventListener(t,e,n),o}}var st=t=>x({},typeof t=="object"?t:null,{once:!0});y.connected=function(t,e){return e=st(e),function(r){return r.addEventListener(A,t,e),r[k]?r:r.isConnected?(r.dispatchEvent(new Event(A)),r):(G(e.signal,()=>R.offConnected(r,t))&&R.onConnected(r,t),r)}};y.disconnected=function(t,e){return e=st(e),function(r){return r.addEventListener(D,t,e),r[k]||G(e.signal,()=>R.offDisconnected(r,t))&&R.onDisconnected(r,t),r}};function kt(t){return d.q(t)}var C=[{get scope(){return d.D.body},host:t=>t?t(d.D.body):d.D.body,prevent:!0}],V=new WeakMap,m={get current(){return C[C.length-1]},get host(){return this.current.host},get signal(){let{host:t}=this;if(V.has(t))return V.get(t);let e=new AbortController;return V.set(t,e),t(y.disconnected(()=>e.abort())),e.signal},preventDefault(){let{current:t}=this;return t.prevent=!0,t},get state(){return[...C]},push(t={}){return C.push(x({},this.current,{prevent:!1},t))},pushRoot(){return C.push(C[0])},pop(){if(C.length!==1)return C.pop()}};function it(...t){return this.appendOriginal(...t),this}function at(t){return t.append===it||(t.appendOriginal=t.append,t.append=it),t}var z;function T(t,e,...n){let r=$(this),o=0,c,s;switch((Object(e)!==e||r.isSignal(e))&&(e={textContent:e}),!0){case typeof t=="function":{o=1;let i=(...h)=>h.length?(o===1?n.unshift(...h):h.forEach(b=>b(s)),void 0):s;m.push({scope:t,host:i}),c=t(e||void 0);let p=S(c,d.F);if(c.nodeName==="#comment")break;let E=T.mark({type:"component",name:t.name,host:p?"this":"parentElement"});c.prepend(E),p&&(s=E);break}case t==="#text":c=W.call(this,d.D.createTextNode(""),e);break;case(t==="<>"||!t):c=W.call(this,d.D.createDocumentFragment(),e);break;case!!z:c=W.call(this,d.D.createElementNS(z,t),e);break;case!c:c=W.call(this,d.D.createElement(t),e)}return at(c),s||(s=c),n.forEach(i=>i(s)),o&&m.pop(),o=2,c}T.mark=function(t,e=!1){t=Object.entries(t).map(([o,c])=>o+`="${c}"`).join(" ");let n=e?"":"/",r=d.D.createComment(``);return e&&(r.end=d.D.createComment("")),r};function Tt(t){let e=this;return function(...r){z=t;let o=T.call(e,...r);return z=void 0,o}}function Mt(t,e=t){let n="\xB9\u2070",r="\u2713",o=Object.fromEntries(Array.from(e.querySelectorAll("slot")).filter(c=>!c.name.endsWith(n)).map(c=>[c.name+=n,c]));if(t.append=new Proxy(t.append,{apply(c,s,i){if(i[0]===e)return c.apply(t,i);for(let p of i){let E=(p.slot||"")+n;try{pt(p,"remove","slot")}catch{}let h=o[E];if(!h)return;h.name.startsWith(r)||(h.childNodes.forEach(b=>b.remove()),h.name=r+E),h.append(p)}return t.append=c,t}}),t!==e){let c=Array.from(t.childNodes);t.append(...c)}return e}var H=new WeakMap,{setDeleteAttr:ut}=d;function W(t,...e){if(!e.length)return t;H.set(t,dt(t,this));for(let[n,r]of Object.entries(x({},...e)))Q.call(this,t,n,r);return H.delete(t),t}function Q(t,e,n){let{setRemoveAttr:r,s:o}=dt(t,this),c=this;n=o.processReactiveAttribute(t,e,n,(i,p)=>Q.call(c,t,i,p));let[s]=e;if(s==="=")return r(e.slice(1),n);if(s===".")return ft(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 ut(t,e,n);case"style":if(typeof n!="object")break;case"dataset":return K(o,e,t,n,ft.bind(null,t[e]));case"ariaset":return K(o,e,t,n,(i,p)=>r("aria-"+i,p));case"classList":return lt.call(c,t,n)}return Pt(t,e)?ut(t,e,n):r(e,n)}function dt(t,e){if(H.has(t))return H.get(t);let r=(S(t,d.S)?jt:qt).bind(null,t,"Attribute"),o=$(e);return{setRemoveAttr:r,s:o}}function lt(t,e){let n=$(this);return K(n,"classList",t,e,(r,o)=>t.classList.toggle(r,o===-1?void 0:!!o)),t}function pt(t,e,n,r){return S(t,d.H)?t[e+"Attribute"](n,r):t[e+"AttributeNS"](null,n,r)}function Pt(t,e){if(!(e in t))return!1;let n=ht(t,e);return!O(n.set)}function ht(t,e){if(t=Object.getPrototypeOf(t),!t)return{};let n=Object.getOwnPropertyDescriptor(t,e);return n||ht(t,e)}function K(t,e,n,r,o){let c=String;if(!(typeof r!="object"||r===null))return Object.entries(r).forEach(function([i,p]){i&&(i=new c(i),i.target=e,p=t.processReactiveAttribute(n,i,p,o),o(i,p))})}function qt(t,e,n,r){return t[(O(r)?"remove":"set")+e](n,r)}function jt(t,e,n,r,o=null){return t[(O(r)?"remove":"set")+e+"NS"](o,n,r)}function ft(t,e,n){if(Reflect.set(t,e,n),!!O(n))return Reflect.deleteProperty(t,e)}function Wt(t,e,n={}){let r=t.host||t;m.push({scope:r,host:(...s)=>s.length?s.forEach(i=>i(r)):r}),typeof n=="function"&&(n=n.call(r,r));let o=r[k];o||gt(r);let c=e.call(r,n);return o||r.dispatchEvent(new Event(A)),t.nodeType===11&&typeof t.mode=="string"&&r.addEventListener(D,R.observe(t),{once:!0}),m.pop(),t.append(c)}function gt(t){return X(t.prototype,"connectedCallback",function(e,n,r){e.apply(n,r),n.dispatchEvent(new Event(A))}),X(t.prototype,"disconnectedCallback",function(e,n,r){e.apply(n,r),(globalThis.queueMicrotask||setTimeout)(()=>!n.isConnected&&n.dispatchEvent(new Event(D)))}),X(t.prototype,"attributeChangedCallback",function(e,n,r){let[o,,c]=r;n.dispatchEvent(new CustomEvent(U,{detail:[o,c]})),e.apply(n,r)}),t.prototype[k]=!0,t}function X(t,e,n){t[e]=new Proxy(t[e]||(()=>{}),{apply:n})}var l="__dde_signal",Y=(()=>{let t=new Set,e=!1;function n(){e=!1;let r=t;t=new Set;for(let o of r){let c=o[l];c&&c.listeners.forEach(s=>s(c.value))}}return function(r){t.add(r),!e&&(e=!0,queueMicrotask(n))}})();var et=w(null,{get:{value(){return vt(this)}},set:{value(...t){return _t(this,...t)}},toJSON:{value(){return vt(this)}},valueOf:{value(){return this[l]&&this[l].value}}}),Ft=w(et,{set:{value(){}}});function F(t){return t&&t[l]}var B=[],v=new WeakMap;function g(t,e){if(typeof t!="function")return mt(!1,t,e);if(F(t))return t;let n=mt(!0);function r(){let[o,...c]=v.get(r);if(v.set(r,new Set([o])),B.push(r),_t(n,t()),B.pop(),!c.length)return;let s=v.get(r);for(let i of c)s.has(i)||N(i,r)}return v.set(n[l],r),v.set(r,new Set([n])),r(),n}g.action=function(t,e,...n){let r=t[l];if(!r)return;let{actions:o}=r;if(!o||!Z(o,e))throw new Error(`Action "${e}" not defined. See ${l}.actions.`);if(o[e].apply(r,n),r.skip)return delete r.skip;Y(t)};g.on=function t(e,n,r={}){let{signal:o}=r;if(!(o&&o.aborted)){if(Array.isArray(e))return e.forEach(c=>t(c,n,r));nt(e,n),o&&o.addEventListener("abort",()=>N(e,n))}};g.symbols={onclear:Symbol.for("Signal.onclear")};g.clear=function(...t){for(let n of t){let r=n[l];r&&(delete n.toJSON,r.onclear.forEach(o=>o.call(r)),e(n,r),delete n[l])}function e(n,r){r.listeners.forEach(o=>{if(r.listeners.delete(o),!v.has(o))return;let c=v.get(o);c.delete(n),!(c.size>1)&&(n.clear(...c),v.delete(o))})}};var L="__dde_reactive";function It(t=w()){return(e,n)=>Z(t,e)?t[e]:t[e]=n()}g.el=function(t,e){let n=T.mark({type:"reactive",source:new q().compact},!0),r=n.end,o=d.D.createDocumentFragment();o.append(n,r);let{current:c}=m,s=w(),i=p=>{if(!n.parentNode||!r.parentNode)return N(t,i);let E=It(s);s=w(),m.push(c);let h=e(p,function(a,f){return s[a]=E(a,f)});m.pop(),Array.isArray(h)||(h=[h]);let b=document.createComment("");h.push(b),n.after(...h);let M;for(;(M=b.nextSibling)&&M!==r;)M.remove();b.remove(),n.isConnected&&$t(c.host())};return nt(t,i),xt(t,i,n,e),i(t.get()),c.host(y.disconnected(()=>s={})),o};function $t(t){!t||!t[L]||(requestIdleCallback||setTimeout)(function(){t[L]=t[L].filter(([e,n])=>n.isConnected?!0:(N(...e),!1))})}var Ut={_set(t){this.value=t}};function zt(t){return function(e,n){let r=w(et,{set:{value(...c){return e.setAttribute(n,...c)}}}),o=Et(r,e.getAttribute(n),Ut);return t[n]=o,o}}var tt="__dde_attributes";g.observedAttributes=function(t){let e=t[tt]={},n=ct(t,zt(e));return y(U,function({detail:o}){/*! This maps attributes to signals (`S.observedAttributes`). Investigate `__dde_attributes` key of the element. */let[c,s]=o,i=this[tt][c];if(i)return g.action(i,"_set",s)})(t),y.disconnected(function(){/*! This removes all signals mapped to attributes (`S.observedAttributes`). - Investigate `__dde_attributes` key of the element. */g.clear(...Object.values(this[tt]))})(t),n};var bt={isSignal:F,processReactiveAttribute(t,e,n,r){if(!F(n))return n;let o=c=>{if(!t.isConnected)return k(n,o);r(e,c)};return nt(n,o),xt(n,o,t,e),n.get()}};function xt(t,e,...n){let{current:r}=m;r.host(function(o){if(o[L])return o[L].push([[t,e],...n]);o[L]=[],!r.prevent&&y.disconnected(()=>o[L].forEach(([[c,s]])=>k(c,s,c[l]&&c[l].host&&c[l].host()===o)))(o)})}var Ht=new FinalizationRegistry(function(t){g.clear({[l]:t})});function mt(t,e,n){let r=w(t?Ft:et),o=Et(r,e,n,t);return Ht.register(o,o[l]),o}var Bt=x(w(),{stopPropagation(){this.skip=!0}});function Et(t,e,n,r=!1){let o=[];rt(n)!=="[object Object]"&&(n={});let{onclear:c}=g.symbols;n[c]&&(o.push(n[c]),delete n[c]);let{host:s}=m;return Reflect.defineProperty(t,l,{value:x(w(Bt),{value:e,actions:n,onclear:o,host:s,listeners:new Set,defined:new q().stack,readonly:r}),enumerable:!1,writable:!1,configurable:!0}),t}function Jt(){return B[B.length-1]}function vt(t){if(!t[l])return;let{value:e,listeners:n}=t[l],r=Jt();return r&&n.add(r),v.has(r)&&v.get(r).add(t),e}function _t(t,e,n){let r=t[l];if(!(!r||!n&&r.value===e))return r.value=e,Y(t),e}function nt(t,e){if(t[l])return t[l].listeners.add(e)}function k(t,e,n){let r=t[l];if(!r)return;let{listeners:o}=r,c=o.delete(e);if(!c||!n||o.size)return c;g.clear(t);let s=v.get(r);if(!s)return c;let i=v.get(s);if(!i)return c;for(let p of i)k(p,s,!0);return c}I(bt);return Ot(Zt);})(); + Investigate `__dde_attributes` key of the element. */g.clear(...Object.values(this[tt]))})(t),n};var bt={isSignal:F,processReactiveAttribute(t,e,n,r){if(!F(n))return n;let o=c=>{if(!t.isConnected)return N(n,o);r(e,c)};return nt(n,o),xt(n,o,t,e),n.get()}};function xt(t,e,...n){let{current:r}=m;r.host(function(o){if(o[L])return o[L].push([[t,e],...n]);o[L]=[],!r.prevent&&y.disconnected(()=>o[L].forEach(([[c,s]])=>N(c,s,c[l]&&c[l].host&&c[l].host()===o)))(o)})}var Ht=new FinalizationRegistry(function(t){g.clear({[l]:t})});function mt(t,e,n){let r=w(t?Ft:et),o=Et(r,e,n,t);return Ht.register(o,o[l]),o}var Bt=x(w(),{stopPropagation(){this.skip=!0}});function Et(t,e,n,r=!1){let o=[];rt(n)!=="[object Object]"&&(n={});let{onclear:c}=g.symbols;n[c]&&(o.push(n[c]),delete n[c]);let{host:s}=m;return Reflect.defineProperty(t,l,{value:x(w(Bt),{value:e,actions:n,onclear:o,host:s,listeners:new Set,defined:new q().stack,readonly:r}),enumerable:!1,writable:!1,configurable:!0}),t}function Jt(){return B[B.length-1]}function vt(t){if(!t[l])return;let{value:e,listeners:n}=t[l],r=Jt();return r&&n.add(r),v.has(r)&&v.get(r).add(t),e}function _t(t,e,n){let r=t[l];if(!(!r||!n&&r.value===e))return r.value=e,Y(t),e}function nt(t,e){if(t[l])return t[l].listeners.add(e)}function N(t,e,n){let r=t[l];if(!r)return;let{listeners:o}=r,c=o.delete(e);if(!c||!n||o.size)return c;g.clear(t);let s=v.get(r);if(!s)return c;let i=v.get(s);if(!i)return c;for(let p of i)N(p,s,!0);return c}I(bt);return Ot(Zt);})(); diff --git a/dist/iife.js b/dist/iife.js index 5f70394..61b7d2c 100644 --- a/dist/iife.js +++ b/dist/iife.js @@ -100,6 +100,7 @@ var DDE = (() => { setDeleteAttr, ssr: "", D: globalThis.document, + N: globalThis.Node, F: globalThis.DocumentFragment, H: globalThis.HTMLElement, S: globalThis.SVGElement, @@ -240,9 +241,9 @@ var DDE = (() => { if (store.size > 30) await requestIdle(); const out = []; - if (!isInstance(element, Node)) return out; + if (!isInstance(element, enviroment.N)) return out; for (const el of store.keys()) { - if (el === element || !isInstance(el, Node)) continue; + if (el === element || !isInstance(el, enviroment.N)) continue; if (element.contains(el)) out.push(el); } diff --git a/dist/iife.min.js b/dist/iife.min.js index a9832cc..be257c2 100644 --- a/dist/iife.min.js +++ b/dist/iife.min.js @@ -1 +1 @@ -var DDE=(()=>{var M=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var nt=Object.prototype.hasOwnProperty;var rt=(t,e)=>{for(var n in e)M(t,n,{get:e[n],enumerable:!0})},ot=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of et(e))!nt.call(t,o)&&o!==n&&M(t,o,{get:()=>e[o],enumerable:!(r=tt(e,o))||r.enumerable});return t};var ct=t=>ot(M({},"__esModule",{value:!0}),t);var bt={};rt(bt,{assign:()=>L,assignAttribute:()=>W,chainableAppend:()=>G,classListDeclarative:()=>J,createElement:()=>P,createElementNS:()=>at,customElementRender:()=>gt,customElementWithDDE:()=>X,dispatchEvent:()=>ut,el:()=>P,elNS:()=>at,elementAttribute:()=>K,lifecyclesToEvents:()=>X,on:()=>S,queue:()=>ft,registerReactivity:()=>$,scope:()=>C,simulateSlots:()=>dt});function w(t){return typeof t>"u"}function g(t,e){return t instanceof e}function I(t,e){return Object.prototype.isPrototypeOf.call(e,t)}function v(...t){return Object.assign(...t)}function j(t,e){if(!t||!g(t,AbortSignal))return!0;if(!t.aborted)return t.addEventListener("abort",e),function(){t.removeEventListener("abort",e)}}var D={isSignal(t){return!1},processReactiveAttribute(t,e,n,r){return n}};function $(t,e=!0){return e?v(D,t):(Object.setPrototypeOf(t,D),t)}function R(t){return I(t,D)&&t!==D?t:D}var a={setDeleteAttr:st,ssr:"",D:globalThis.document,F:globalThis.DocumentFragment,H:globalThis.HTMLElement,S:globalThis.SVGElement,M:globalThis.MutationObserver,q:t=>t||Promise.resolve()};function st(t,e,n){if(Reflect.set(t,e,n),!!w(n)){if(Reflect.deleteProperty(t,e),g(t,a.H)&&t.getAttribute(e)==="undefined")return t.removeAttribute(e);if(Reflect.get(t,e)==="undefined")return Reflect.set(t,e,"")}}var y="__dde_lifecyclesToEvents",m="dde:connected",_="dde:disconnected",U="dde:attributeChanged";var O=a.M?it():new Proxy({},{get(){return()=>{}}});function it(){let t=new Map,e=!1,n=s=>function(u){for(let i of u)if(i.type==="childList"){if(l(i.addedNodes,!0)){s();continue}E(i.removedNodes,!0)&&s()}},r=new a.M(n(f));return{observe(s){let u=new a.M(n(()=>{}));return u.observe(s,{childList:!0,subtree:!0}),()=>u.disconnect()},onConnected(s,u){d();let i=c(s);i.connected.has(u)||(i.connected.add(u),i.length_c+=1)},offConnected(s,u){if(!t.has(s))return;let i=t.get(s);i.connected.has(u)&&(i.connected.delete(u),i.length_c-=1,o(s,i))},onDisconnected(s,u){d();let i=c(s);i.disconnected.has(u)||(i.disconnected.add(u),i.length_d+=1)},offDisconnected(s,u){if(!t.has(s))return;let i=t.get(s);i.disconnected.delete(u),i.length_d-=1,o(s,i)}};function o(s,u){u.length_c||u.length_d||(t.delete(s),f())}function c(s){if(t.has(s))return t.get(s);let u={connected:new WeakSet,length_c:0,disconnected:new WeakSet,length_d:0};return t.set(s,u),u}function d(){e||(e=!0,r.observe(a.D.body,{childList:!0,subtree:!0}))}function f(){!e||t.size||(e=!1,r.disconnect())}function p(){return new Promise(function(s){(requestIdleCallback||requestAnimationFrame)(s)})}async function b(s){t.size>30&&await p();let u=[];if(!g(s,Node))return u;for(let i of t.keys())i===s||!g(i,Node)||s.contains(i)&&u.push(i);return u}function l(s,u){let i=!1;for(let h of s){if(u&&b(h).then(l),!t.has(h))continue;let A=t.get(h);A.length_c&&(h.dispatchEvent(new Event(m)),A.connected=new WeakSet,A.length_c=0,A.length_d||t.delete(h),i=!0)}return i}function E(s,u){let i=!1;for(let h of s)u&&b(h).then(E),!(!t.has(h)||!t.get(h).length_d)&&((globalThis.queueMicrotask||setTimeout)(Y(h)),i=!0);return i}function Y(s){return()=>{s.isConnected||(s.dispatchEvent(new Event(_)),t.delete(s))}}}function ut(t,e,n){return typeof e=="function"&&(n=e,e=null),e||(e={}),function(o,...c){n&&(c.unshift(o),o=typeof n=="function"?n():n);let d=c.length?new CustomEvent(t,v({detail:c[0]},e)):new Event(t,e);return o.dispatchEvent(d)}}function S(t,e,n){return function(o){return o.addEventListener(t,e,n),o}}var H=t=>v({},typeof t=="object"?t:null,{once:!0});S.connected=function(t,e){return e=H(e),function(r){return r.addEventListener(m,t,e),r[y]?r:r.isConnected?(r.dispatchEvent(new Event(m)),r):(j(e.signal,()=>O.offConnected(r,t))&&O.onConnected(r,t),r)}};S.disconnected=function(t,e){return e=H(e),function(r){return r.addEventListener(_,t,e),r[y]||j(e.signal,()=>O.offDisconnected(r,t))&&O.onDisconnected(r,t),r}};function ft(t){return a.q(t)}var x=[{get scope(){return a.D.body},host:t=>t?t(a.D.body):a.D.body,prevent:!0}],k=new WeakMap,C={get current(){return x[x.length-1]},get host(){return this.current.host},get signal(){let{host:t}=this;if(k.has(t))return k.get(t);let e=new AbortController;return k.set(t,e),t(S.disconnected(()=>e.abort())),e.signal},preventDefault(){let{current:t}=this;return t.prevent=!0,t},get state(){return[...x]},push(t={}){return x.push(v({},this.current,{prevent:!1},t))},pushRoot(){return x.push(x[0])},pop(){if(x.length!==1)return x.pop()}};function z(...t){return this.appendOriginal(...t),this}function G(t){return t.append===z||(t.appendOriginal=t.append,t.append=z),t}var T;function P(t,e,...n){let r=R(this),o=0,c,d;switch((Object(e)!==e||r.isSignal(e))&&(e={textContent:e}),!0){case typeof t=="function":{o=1;let f=(...l)=>l.length?(o===1?n.unshift(...l):l.forEach(E=>E(d)),void 0):d;C.push({scope:t,host:f}),c=t(e||void 0);let p=g(c,a.F);if(c.nodeName==="#comment")break;let b=P.mark({type:"component",name:t.name,host:p?"this":"parentElement"});c.prepend(b),p&&(d=b);break}case t==="#text":c=L.call(this,a.D.createTextNode(""),e);break;case(t==="<>"||!t):c=L.call(this,a.D.createDocumentFragment(),e);break;case!!T:c=L.call(this,a.D.createElementNS(T,t),e);break;case!c:c=L.call(this,a.D.createElement(t),e)}return G(c),d||(d=c),n.forEach(f=>f(d)),o&&C.pop(),o=2,c}P.mark=function(t,e=!1){t=Object.entries(t).map(([o,c])=>o+`="${c}"`).join(" ");let n=e?"":"/",r=a.D.createComment(``);return e&&(r.end=a.D.createComment("")),r};function at(t){let e=this;return function(...r){T=t;let o=P.call(e,...r);return T=void 0,o}}function dt(t,e=t){let n="\xB9\u2070",r="\u2713",o=Object.fromEntries(Array.from(e.querySelectorAll("slot")).filter(c=>!c.name.endsWith(n)).map(c=>[c.name+=n,c]));if(t.append=new Proxy(t.append,{apply(c,d,f){if(f[0]===e)return c.apply(t,f);for(let p of f){let b=(p.slot||"")+n;try{K(p,"remove","slot")}catch{}let l=o[b];if(!l)return;l.name.startsWith(r)||(l.childNodes.forEach(E=>E.remove()),l.name=r+b),l.append(p)}return t.append=c,t}}),t!==e){let c=Array.from(t.childNodes);t.append(...c)}return e}var N=new WeakMap,{setDeleteAttr:B}=a;function L(t,...e){if(!e.length)return t;N.set(t,V(t,this));for(let[n,r]of Object.entries(v({},...e)))W.call(this,t,n,r);return N.delete(t),t}function W(t,e,n){let{setRemoveAttr:r,s:o}=V(t,this),c=this;n=o.processReactiveAttribute(t,e,n,(f,p)=>W.call(c,t,f,p));let[d]=e;if(d==="=")return r(e.slice(1),n);if(d===".")return Z(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 B(t,e,n);case"style":if(typeof n!="object")break;case"dataset":return q(o,e,t,n,Z.bind(null,t[e]));case"ariaset":return q(o,e,t,n,(f,p)=>r("aria-"+f,p));case"classList":return J.call(c,t,n)}return pt(t,e)?B(t,e,n):r(e,n)}function V(t,e){if(N.has(t))return N.get(t);let r=(g(t,a.S)?ht:lt).bind(null,t,"Attribute"),o=R(e);return{setRemoveAttr:r,s:o}}function J(t,e){let n=R(this);return q(n,"classList",t,e,(r,o)=>t.classList.toggle(r,o===-1?void 0:!!o)),t}function K(t,e,n,r){return g(t,a.H)?t[e+"Attribute"](n,r):t[e+"AttributeNS"](null,n,r)}function pt(t,e){if(!(e in t))return!1;let n=Q(t,e);return!w(n.set)}function Q(t,e){if(t=Object.getPrototypeOf(t),!t)return{};let n=Object.getOwnPropertyDescriptor(t,e);return n||Q(t,e)}function q(t,e,n,r,o){let c=String;if(!(typeof r!="object"||r===null))return Object.entries(r).forEach(function([f,p]){f&&(f=new c(f),f.target=e,p=t.processReactiveAttribute(n,f,p,o),o(f,p))})}function lt(t,e,n,r){return t[(w(r)?"remove":"set")+e](n,r)}function ht(t,e,n,r,o=null){return t[(w(r)?"remove":"set")+e+"NS"](o,n,r)}function Z(t,e,n){if(Reflect.set(t,e,n),!!w(n))return Reflect.deleteProperty(t,e)}function gt(t,e,n={}){let r=t.host||t;C.push({scope:r,host:(...d)=>d.length?d.forEach(f=>f(r)):r}),typeof n=="function"&&(n=n.call(r,r));let o=r[y];o||X(r);let c=e.call(r,n);return o||r.dispatchEvent(new Event(m)),t.nodeType===11&&typeof t.mode=="string"&&r.addEventListener(_,O.observe(t),{once:!0}),C.pop(),t.append(c)}function X(t){return F(t.prototype,"connectedCallback",function(e,n,r){e.apply(n,r),n.dispatchEvent(new Event(m))}),F(t.prototype,"disconnectedCallback",function(e,n,r){e.apply(n,r),(globalThis.queueMicrotask||setTimeout)(()=>!n.isConnected&&n.dispatchEvent(new Event(_)))}),F(t.prototype,"attributeChangedCallback",function(e,n,r){let[o,,c]=r;n.dispatchEvent(new CustomEvent(U,{detail:[o,c]})),e.apply(n,r)}),t.prototype[y]=!0,t}function F(t,e,n){t[e]=new Proxy(t[e]||(()=>{}),{apply:n})}return ct(bt);})(); +var DDE=(()=>{var M=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var nt=Object.prototype.hasOwnProperty;var rt=(t,e)=>{for(var n in e)M(t,n,{get:e[n],enumerable:!0})},ot=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of et(e))!nt.call(t,o)&&o!==n&&M(t,o,{get:()=>e[o],enumerable:!(r=tt(e,o))||r.enumerable});return t};var ct=t=>ot(M({},"__esModule",{value:!0}),t);var bt={};rt(bt,{assign:()=>L,assignAttribute:()=>W,chainableAppend:()=>G,classListDeclarative:()=>J,createElement:()=>P,createElementNS:()=>at,customElementRender:()=>gt,customElementWithDDE:()=>X,dispatchEvent:()=>ut,el:()=>P,elNS:()=>at,elementAttribute:()=>K,lifecyclesToEvents:()=>X,on:()=>S,queue:()=>ft,registerReactivity:()=>$,scope:()=>C,simulateSlots:()=>dt});function w(t){return typeof t>"u"}function g(t,e){return t instanceof e}function I(t,e){return Object.prototype.isPrototypeOf.call(e,t)}function v(...t){return Object.assign(...t)}function j(t,e){if(!t||!g(t,AbortSignal))return!0;if(!t.aborted)return t.addEventListener("abort",e),function(){t.removeEventListener("abort",e)}}var D={isSignal(t){return!1},processReactiveAttribute(t,e,n,r){return n}};function $(t,e=!0){return e?v(D,t):(Object.setPrototypeOf(t,D),t)}function R(t){return I(t,D)&&t!==D?t:D}var f={setDeleteAttr:st,ssr:"",D:globalThis.document,N:globalThis.Node,F:globalThis.DocumentFragment,H:globalThis.HTMLElement,S:globalThis.SVGElement,M:globalThis.MutationObserver,q:t=>t||Promise.resolve()};function st(t,e,n){if(Reflect.set(t,e,n),!!w(n)){if(Reflect.deleteProperty(t,e),g(t,f.H)&&t.getAttribute(e)==="undefined")return t.removeAttribute(e);if(Reflect.get(t,e)==="undefined")return Reflect.set(t,e,"")}}var y="__dde_lifecyclesToEvents",m="dde:connected",_="dde:disconnected",U="dde:attributeChanged";var O=f.M?it():new Proxy({},{get(){return()=>{}}});function it(){let t=new Map,e=!1,n=s=>function(u){for(let i of u)if(i.type==="childList"){if(l(i.addedNodes,!0)){s();continue}E(i.removedNodes,!0)&&s()}},r=new f.M(n(a));return{observe(s){let u=new f.M(n(()=>{}));return u.observe(s,{childList:!0,subtree:!0}),()=>u.disconnect()},onConnected(s,u){d();let i=c(s);i.connected.has(u)||(i.connected.add(u),i.length_c+=1)},offConnected(s,u){if(!t.has(s))return;let i=t.get(s);i.connected.has(u)&&(i.connected.delete(u),i.length_c-=1,o(s,i))},onDisconnected(s,u){d();let i=c(s);i.disconnected.has(u)||(i.disconnected.add(u),i.length_d+=1)},offDisconnected(s,u){if(!t.has(s))return;let i=t.get(s);i.disconnected.delete(u),i.length_d-=1,o(s,i)}};function o(s,u){u.length_c||u.length_d||(t.delete(s),a())}function c(s){if(t.has(s))return t.get(s);let u={connected:new WeakSet,length_c:0,disconnected:new WeakSet,length_d:0};return t.set(s,u),u}function d(){e||(e=!0,r.observe(f.D.body,{childList:!0,subtree:!0}))}function a(){!e||t.size||(e=!1,r.disconnect())}function p(){return new Promise(function(s){(requestIdleCallback||requestAnimationFrame)(s)})}async function b(s){t.size>30&&await p();let u=[];if(!g(s,f.N))return u;for(let i of t.keys())i===s||!g(i,f.N)||s.contains(i)&&u.push(i);return u}function l(s,u){let i=!1;for(let h of s){if(u&&b(h).then(l),!t.has(h))continue;let A=t.get(h);A.length_c&&(h.dispatchEvent(new Event(m)),A.connected=new WeakSet,A.length_c=0,A.length_d||t.delete(h),i=!0)}return i}function E(s,u){let i=!1;for(let h of s)u&&b(h).then(E),!(!t.has(h)||!t.get(h).length_d)&&((globalThis.queueMicrotask||setTimeout)(Y(h)),i=!0);return i}function Y(s){return()=>{s.isConnected||(s.dispatchEvent(new Event(_)),t.delete(s))}}}function ut(t,e,n){return typeof e=="function"&&(n=e,e=null),e||(e={}),function(o,...c){n&&(c.unshift(o),o=typeof n=="function"?n():n);let d=c.length?new CustomEvent(t,v({detail:c[0]},e)):new Event(t,e);return o.dispatchEvent(d)}}function S(t,e,n){return function(o){return o.addEventListener(t,e,n),o}}var H=t=>v({},typeof t=="object"?t:null,{once:!0});S.connected=function(t,e){return e=H(e),function(r){return r.addEventListener(m,t,e),r[y]?r:r.isConnected?(r.dispatchEvent(new Event(m)),r):(j(e.signal,()=>O.offConnected(r,t))&&O.onConnected(r,t),r)}};S.disconnected=function(t,e){return e=H(e),function(r){return r.addEventListener(_,t,e),r[y]||j(e.signal,()=>O.offDisconnected(r,t))&&O.onDisconnected(r,t),r}};function ft(t){return f.q(t)}var x=[{get scope(){return f.D.body},host:t=>t?t(f.D.body):f.D.body,prevent:!0}],k=new WeakMap,C={get current(){return x[x.length-1]},get host(){return this.current.host},get signal(){let{host:t}=this;if(k.has(t))return k.get(t);let e=new AbortController;return k.set(t,e),t(S.disconnected(()=>e.abort())),e.signal},preventDefault(){let{current:t}=this;return t.prevent=!0,t},get state(){return[...x]},push(t={}){return x.push(v({},this.current,{prevent:!1},t))},pushRoot(){return x.push(x[0])},pop(){if(x.length!==1)return x.pop()}};function z(...t){return this.appendOriginal(...t),this}function G(t){return t.append===z||(t.appendOriginal=t.append,t.append=z),t}var T;function P(t,e,...n){let r=R(this),o=0,c,d;switch((Object(e)!==e||r.isSignal(e))&&(e={textContent:e}),!0){case typeof t=="function":{o=1;let a=(...l)=>l.length?(o===1?n.unshift(...l):l.forEach(E=>E(d)),void 0):d;C.push({scope:t,host:a}),c=t(e||void 0);let p=g(c,f.F);if(c.nodeName==="#comment")break;let b=P.mark({type:"component",name:t.name,host:p?"this":"parentElement"});c.prepend(b),p&&(d=b);break}case t==="#text":c=L.call(this,f.D.createTextNode(""),e);break;case(t==="<>"||!t):c=L.call(this,f.D.createDocumentFragment(),e);break;case!!T:c=L.call(this,f.D.createElementNS(T,t),e);break;case!c:c=L.call(this,f.D.createElement(t),e)}return G(c),d||(d=c),n.forEach(a=>a(d)),o&&C.pop(),o=2,c}P.mark=function(t,e=!1){t=Object.entries(t).map(([o,c])=>o+`="${c}"`).join(" ");let n=e?"":"/",r=f.D.createComment(``);return e&&(r.end=f.D.createComment("")),r};function at(t){let e=this;return function(...r){T=t;let o=P.call(e,...r);return T=void 0,o}}function dt(t,e=t){let n="\xB9\u2070",r="\u2713",o=Object.fromEntries(Array.from(e.querySelectorAll("slot")).filter(c=>!c.name.endsWith(n)).map(c=>[c.name+=n,c]));if(t.append=new Proxy(t.append,{apply(c,d,a){if(a[0]===e)return c.apply(t,a);for(let p of a){let b=(p.slot||"")+n;try{K(p,"remove","slot")}catch{}let l=o[b];if(!l)return;l.name.startsWith(r)||(l.childNodes.forEach(E=>E.remove()),l.name=r+b),l.append(p)}return t.append=c,t}}),t!==e){let c=Array.from(t.childNodes);t.append(...c)}return e}var N=new WeakMap,{setDeleteAttr:B}=f;function L(t,...e){if(!e.length)return t;N.set(t,V(t,this));for(let[n,r]of Object.entries(v({},...e)))W.call(this,t,n,r);return N.delete(t),t}function W(t,e,n){let{setRemoveAttr:r,s:o}=V(t,this),c=this;n=o.processReactiveAttribute(t,e,n,(a,p)=>W.call(c,t,a,p));let[d]=e;if(d==="=")return r(e.slice(1),n);if(d===".")return Z(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 B(t,e,n);case"style":if(typeof n!="object")break;case"dataset":return q(o,e,t,n,Z.bind(null,t[e]));case"ariaset":return q(o,e,t,n,(a,p)=>r("aria-"+a,p));case"classList":return J.call(c,t,n)}return pt(t,e)?B(t,e,n):r(e,n)}function V(t,e){if(N.has(t))return N.get(t);let r=(g(t,f.S)?ht:lt).bind(null,t,"Attribute"),o=R(e);return{setRemoveAttr:r,s:o}}function J(t,e){let n=R(this);return q(n,"classList",t,e,(r,o)=>t.classList.toggle(r,o===-1?void 0:!!o)),t}function K(t,e,n,r){return g(t,f.H)?t[e+"Attribute"](n,r):t[e+"AttributeNS"](null,n,r)}function pt(t,e){if(!(e in t))return!1;let n=Q(t,e);return!w(n.set)}function Q(t,e){if(t=Object.getPrototypeOf(t),!t)return{};let n=Object.getOwnPropertyDescriptor(t,e);return n||Q(t,e)}function q(t,e,n,r,o){let c=String;if(!(typeof r!="object"||r===null))return Object.entries(r).forEach(function([a,p]){a&&(a=new c(a),a.target=e,p=t.processReactiveAttribute(n,a,p,o),o(a,p))})}function lt(t,e,n,r){return t[(w(r)?"remove":"set")+e](n,r)}function ht(t,e,n,r,o=null){return t[(w(r)?"remove":"set")+e+"NS"](o,n,r)}function Z(t,e,n){if(Reflect.set(t,e,n),!!w(n))return Reflect.deleteProperty(t,e)}function gt(t,e,n={}){let r=t.host||t;C.push({scope:r,host:(...d)=>d.length?d.forEach(a=>a(r)):r}),typeof n=="function"&&(n=n.call(r,r));let o=r[y];o||X(r);let c=e.call(r,n);return o||r.dispatchEvent(new Event(m)),t.nodeType===11&&typeof t.mode=="string"&&r.addEventListener(_,O.observe(t),{once:!0}),C.pop(),t.append(c)}function X(t){return F(t.prototype,"connectedCallback",function(e,n,r){e.apply(n,r),n.dispatchEvent(new Event(m))}),F(t.prototype,"disconnectedCallback",function(e,n,r){e.apply(n,r),(globalThis.queueMicrotask||setTimeout)(()=>!n.isConnected&&n.dispatchEvent(new Event(_)))}),F(t.prototype,"attributeChangedCallback",function(e,n,r){let[o,,c]=r;n.dispatchEvent(new CustomEvent(U,{detail:[o,c]})),e.apply(n,r)}),t.prototype[y]=!0,t}function F(t,e,n){t[e]=new Proxy(t[e]||(()=>{}),{apply:n})}return ct(bt);})(); diff --git a/jsdom.js b/jsdom.js index 8344ae4..fb25dba 100644 --- a/jsdom.js +++ b/jsdom.js @@ -1,4 +1,3 @@ -//TODO: https://www.npmjs.com/package/html-element import { enviroment as env } from './src/dom-common.js'; env.ssr= " ssr"; @@ -17,7 +16,7 @@ env.setDeleteAttr= function(obj, prop, value){ if(value) return obj.setAttribute(prop, ""); obj.removeAttribute(prop); }; -const keys= { H: "HTMLElement", S: "SVGElement", F: "DocumentFragment", D: "document" }; +const keys= { N: "Node", H: "HTMLElement", S: "SVGElement", F: "DocumentFragment", D: "document", M: "MutationObserver" }; let env_bk= {}; let dom_last; diff --git a/src/dom-common.js b/src/dom-common.js index ba08da1..7caa2f2 100644 --- a/src/dom-common.js +++ b/src/dom-common.js @@ -14,6 +14,7 @@ export const enviroment= { setDeleteAttr, ssr: "", D: globalThis.document, + N: globalThis.Node, F: globalThis.DocumentFragment, H: globalThis.HTMLElement, S: globalThis.SVGElement, diff --git a/src/events-observer.js b/src/events-observer.js index 5ac925f..83935ba 100644 --- a/src/events-observer.js +++ b/src/events-observer.js @@ -167,9 +167,9 @@ function connectionsChangesObserverConstructor(){ if(store.size > 30)//TODO?: limit await requestIdle(); const out= []; - if(!isInstance(element, Node)) return out; + if(!isInstance(element, env.N)) return out; for(const el of store.keys()){ - if(el===element || !isInstance(el, Node)) continue; + if(el===element || !isInstance(el, env.N)) continue; if(element.contains(el)) out.push(el); }