MCPcopy Create free account
hub / github.com/DTStack/molecule / findParentByClassName

Function findParentByClassName

src/common/dom.ts:84–97  ·  view source on GitHub ↗
(element, className)

Source from the content-addressed store, hash-verified

82}
83
84export function findParentByClassName<T>(element, className): T | null {
85 try {
86 while (element && element) {
87 const classes = element.getAttribute('class');
88 if (classes && classes.indexOf(className) > -1) {
89 return element;
90 }
91 element = element.parentElement;
92 }
93 } catch (e) {
94 throw new Error(`findParentByClassName error: ${e}`);
95 }
96 return null;
97}
98
99export function triggerEvent(trigger: TriggerEvent) {
100 switch (trigger) {

Callers 1

dom.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected