2021-12-11 15:00:30 +01:00
|
|
|
export { is, isAny } from '../../../util/ModelUtil';
|
2015-10-10 01:40:52 +02:00
|
|
|
|
2021-12-11 15:00:30 +01:00
|
|
|
import { isAny } from '../../../util/ModelUtil';
|
2015-10-10 01:40:52 +02:00
|
|
|
|
|
|
|
/**
|
2018-03-22 12:43:36 +01:00
|
|
|
* Return the parent of the element with any of the given types.
|
2015-10-10 01:40:52 +02:00
|
|
|
*
|
|
|
|
* @param {djs.model.Base} element
|
2020-04-03 15:51:45 +02:00
|
|
|
* @param {string|Array<string>} anyType
|
2015-10-10 01:40:52 +02:00
|
|
|
*
|
|
|
|
* @return {djs.model.Base}
|
|
|
|
*/
|
2018-04-02 21:01:53 +02:00
|
|
|
export function getParent(element, anyType) {
|
2015-10-10 01:40:52 +02:00
|
|
|
|
|
|
|
if (typeof anyType === 'string') {
|
|
|
|
anyType = [ anyType ];
|
|
|
|
}
|
|
|
|
|
|
|
|
while ((element = element.parent)) {
|
|
|
|
if (isAny(element, anyType)) {
|
|
|
|
return element;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2018-04-02 21:01:53 +02:00
|
|
|
}
|