export function findFirstElement(selector: string): HTMLElement | null { const elements = document.querySelectorAll(selector); return elements.length > 0 ? elements[0] as HTMLElement : null; } export function findFirstChildElement(selector: string, root: Element): HTMLElement | null { const elements = root.querySelectorAll(selector); return elements.length > 0 ? elements[0] as HTMLElement : null; }