mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-02 07:20:38 +00:00
15 lines
331 B
TypeScript
15 lines
331 B
TypeScript
// 仅使用类型
|
|
import { Node } from '@ali/lowcode-designer';
|
|
|
|
export const getClosestNode = (node: Node, until: (node: Node) => boolean): Node | undefined => {
|
|
if (!node) {
|
|
return undefined;
|
|
}
|
|
if (until(node)) {
|
|
return node;
|
|
} else {
|
|
// @ts-ignore
|
|
return getClosestNode(node.getParent(), until);
|
|
}
|
|
};
|