@haxtheweb/haxcms-nodejs
Version:
HAXcms single and multisite nodejs server, api, and administration
1 lines • 454 B
JavaScript
export function queryShadowRoot(o,e,t,r=20,n=0){let u=[];if(n>=r)return u;const traverseSlot=o=>{const u=o.assignedNodes().filter((o=>1===o.nodeType));return u.length>0?queryShadowRoot(u[0].parentElement,e,t,r,n+1):[]},h=Array.from(o.children||[]);for(const o of h)e(o)||(t(o)&&u.push(o),null!=o.shadowRoot?u.push(...queryShadowRoot(o.shadowRoot,e,t,r,n+1)):"SLOT"===o.tagName?u.push(...traverseSlot(o)):u.push(...queryShadowRoot(o,e,t,r,n+1)));return u}