mirror of
https://github.com/csunny/DB-GPT.git
synced 2026-07-16 17:15:22 +00:00
Co-authored-by: lusain <lusain1990@gmail.com> Co-authored-by: alan.cl <1165243776@qq.com> Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
16 lines
446 B
TypeScript
16 lines
446 B
TypeScript
/**
|
|
* Find the closest parent element with a specific class name.
|
|
*/
|
|
export function findParentElementByClassName(element: Element | null, className: string): Element | null {
|
|
if (!element) return null;
|
|
|
|
let currentElement: Element | null = element;
|
|
while (currentElement) {
|
|
if (currentElement.classList.contains(className)) {
|
|
return currentElement;
|
|
}
|
|
currentElement = currentElement.parentElement;
|
|
}
|
|
return null;
|
|
}
|