# all files / Github/bpmn-js/lib/features/modeling/util/ ModelingUtil.js

87.5% Statements 7/8
75% Branches 3/4
100% Functions 3/3
87.5% Lines 7/8

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44

    32622×
    119269×

    1105×

    1105×
    1126×
    1031×

    74×
     import {
      some
    } from 'min-dash';

    import { is } from '../../../util/ModelUtil';

    /**
     * Return true if element has any of the given types.
     *
     * @param {djs.model.Base} element
     * @param {Array<String>} types
     *
     * @return {Boolean}
     */
    export function isAny(element, types) {
      return some(types, function(t) {
        return is(element, t);
      });
    }

    /**
     * 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) {

      Iif (typeof anyType === 'string') {
        anyType = [ anyType ];
      }

      while ((element = element.parent)) {
        if (isAny(element, anyType)) {
          return element;
        }
      }

      return null;
    }