tweb-i2p/src/helpers/dom/findUpAttribute.ts
2021-08-03 04:30:06 +03:00

18 lines
504 B
TypeScript

/*
* https://github.com/morethanwords/tweb
* Copyright (C) 2019-2021 Eduard Kuzmenko
* https://github.com/morethanwords/tweb/blob/master/LICENSE
*/
export default function findUpAttribute(el: any, attribute: string): HTMLElement {
return el.closest(`[${attribute}]`);
/* if(el.getAttribute(attribute) !== null) return el; // 03.02.2020
while(el.parentElement) {
el = el.parentElement;
if(el.getAttribute(attribute) !== null)
return el;
}
return null; */
}