added prototype
This commit is contained in:
@@ -9,3 +9,13 @@ export const querySelectorTyped = <T extends HTMLElement>(
|
||||
}
|
||||
return element;
|
||||
};
|
||||
|
||||
// Helferfunktion aus jQuery (youmightnotjquery)
|
||||
export const parents = (el: HTMLElement, selector?: string): HTMLElement[] => {
|
||||
const parents: HTMLElement[] = [];
|
||||
let currentEl: HTMLElement | null = el;
|
||||
while ((currentEl = currentEl.parentElement) && currentEl !== null && currentEl !== document.documentElement) {
|
||||
if (!selector || currentEl.matches(selector)) parents.push(currentEl as HTMLElement);
|
||||
}
|
||||
return parents;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user