mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-01-19 13:31:06 +00:00
2b11d871cd
In the diagram `di` is now accessed via the diagram element, not the business object. This has the benefit that elements in multiple diagrams can easily be represented. Related to https://github.com/bpmn-io/bpmn-js/issues/1472 BREAKING CHANGE: * Instead of referencing the `di` from the business object, reference it from the diagram element representing it.
36 lines
745 B
JavaScript
36 lines
745 B
JavaScript
/**
|
|
* 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;
|
|
}
|
|
|
|
/**
|
|
* Return the di object for a given element.
|
|
*
|
|
* @param {djs.model.Base} element
|
|
*
|
|
* @return {ModdleElement}
|
|
*/
|
|
export function getDi(element) {
|
|
return element && element.di;
|
|
} |