This repository has been archived on 2022-05-10. You can view files and clone it, but cannot push or open issues or pull requests.
tghandbook/src/utils.ts

16 lines
318 B
TypeScript

export function findParent(
base: HTMLElement,
matchFn: (candidate: HTMLElement) => boolean
): HTMLElement | null {
let parent = base.parentElement;
while (parent != null) {
if (matchFn(parent)) {
break;
}
parent = parent.parentElement;
}
return parent;
}
export default { findParent };