all files / bpmn-js/lib/util/ ModelUtil.js

100% Statements 3/3
100% Branches 6/6
100% Functions 2/2
100% Lines 3/3
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                  637882×   637882×                       662514×  
/**
 * Is an element of the given BPMN type?
 *
 * @param  {djs.model.Base|ModdleElement} element
 * @param  {String} type
 *
 * @return {Boolean}
 */
export function is(element, type) {
  var bo = getBusinessObject(element);
 
  return bo && (typeof bo.$instanceOf === 'function') && bo.$instanceOf(type);
}
 
 
/**
 * Return the business object for a given element.
 *
 * @param  {djs.model.Base|ModdleElement} element
 *
 * @return {ModdleElement}
 */
export function getBusinessObject(element) {
  return (element && element.businessObject) || element;
}