tweb-i2p/src/helpers/dom/findUpClassName.ts
2021-04-08 17:52:31 +04:00

19 lines
549 B
TypeScript

/*
* https://github.com/morethanwords/tweb
* Copyright (C) 2019-2021 Eduard Kuzmenko
* https://github.com/morethanwords/tweb/blob/master/LICENSE
*/
//export function findUpClassName<T>(el: any, className: string): T;
export default function findUpClassName(el: any, className: string): HTMLElement {
return el.closest('.' + className);
/* if(el.classList.contains(className)) return el; // 03.02.2020
while(el.parentElement) {
el = el.parentElement;
if(el.classList.contains(className))
return el;
}
return null; */
}