Files
DB-GPT/web/utils/dom.ts
Aries-ckt ef83851b31 🎉 DB-GPT V0.8.0 - Beta Testing (#2988)
Co-authored-by: lusain <lusain1990@gmail.com>
Co-authored-by: alan.cl <1165243776@qq.com>
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-16 11:55:42 +08:00

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;
}