Files
tf2wikipricing/src/content/utils/dom.ts
xenticore 12de4a7148 refactor: moved components to separate modules
`content.ts` is now half less than the size, exported functions can be unit tested
2025-03-24 15:39:28 -04:00

10 lines
407 B
TypeScript

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;
}