ModelUtil.js 555 B

12345678910111213141516171819202122232425
  1. /**
  2. * Is an element of the given BPMN type?
  3. *
  4. * @param {djs.model.Base|ModdleElement} element
  5. * @param {string} type
  6. *
  7. * @return {boolean}
  8. */
  9. export function is(element, type) {
  10. var bo = getBusinessObject(element);
  11. return bo && (typeof bo.$instanceOf === 'function') && bo.$instanceOf(type);
  12. }
  13. /**
  14. * Return the business object for a given element.
  15. *
  16. * @param {djs.model.Base|ModdleElement} element
  17. *
  18. * @return {ModdleElement}
  19. */
  20. export function getBusinessObject(element) {
  21. return (element && element.businessObject) || element;
  22. }