You've already forked tf2wikipricing
refactor: moved components to separate modules
`content.ts` is now half less than the size, exported functions can be unit tested
This commit is contained in:
9
src/content/utils/dom.ts
Normal file
9
src/content/utils/dom.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user