You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
526 B
26 lines
526 B
2 years ago
|
export { is, isAny } from '../../../util/ModelUtil';
|
||
|
|
||
|
import { isAny } from '../../../util/ModelUtil';
|
||
|
|
||
|
/**
|
||
|
* Return the parent of the element with any of the given types.
|
||
|
*
|
||
|
* @param {djs.model.Base} element
|
||
|
* @param {string|Array<string>} anyType
|
||
|
*
|
||
|
* @return {djs.model.Base}
|
||
|
*/
|
||
|
export function getParent(element, anyType) {
|
||
|
|
||
|
if (typeof anyType === 'string') {
|
||
|
anyType = [ anyType ];
|
||
|
}
|
||
|
|
||
|
while ((element = element.parent)) {
|
||
|
if (isAny(element, anyType)) {
|
||
|
return element;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
}
|