Last active: 2 years ago
/**
* 遍历父元素类名
* 查询是否有对应类名
* @returns
*/
const parentClassChecker = (el: HTMLElement | null): boolean => {
if (!el) return false;
if (!el?.classList) return parentClassChecker(el.parentElement);
return (
!!Array.from(el.classList).filter((item) =>
['more-language', 'popbtn-list', 'view-control'].includes(item)
).length || parentClassChecker(el.parentElement)
);
};
/**
* Check element's id and it's parents
* @param el
* @returns
*/
const parentIdChecker = (el: HTMLElement | null): boolean => {
if (!el) return false;
if (!el?.id) return parentIdChecker(el.parentElement);
return (
!!['menu', 'menu-icon'].filter((item) => item === el.id).length ||
parentIdChecker(el.parentElement)
);
};