import {getShadowRoot} from './getShadowRoot.js'; import {lispToCamel} from './lispToCamel.js'; /** * @deprecated -- use mount-observer/upShadowSearch * @param ref * @param cssSel * @returns */ export function upShadowSearch(ref: Element, cssSel: string){ const split = cssSel.split('/'); const id = split[split.length - 1]; let targetElement: Element | null; if (cssSel.startsWith('/')) { targetElement = (self)[cssSel.substr(1)]; } else{ const len = cssSel.startsWith('../') ? split.length : 0; const shadowRoot = getShadowRoot(ref as HTMLElement, len) as ShadowRoot; if (shadowRoot !== undefined) { if(len === 0 && shadowRoot.host){ targetElement = ((shadowRoot).host)[lispToCamel(id)]; if(targetElement !== undefined) return targetElement; } targetElement = shadowRoot.getElementById(id) as HTMLElement; } else { throw 'Target Element Not found'; } } return targetElement; }