UNPKG

729 BJavaScriptView Raw
1import {
2 has
3} from 'min-dash';
4
5/**
6 * @typedef {import('../model/Types').ModdleElement} ModdleElement
7 */
8
9
10// TODO(nikku): remove with future bpmn-js version
11
12var DI_ERROR_MESSAGE = 'Tried to access di from the businessObject. The di is available through the diagram element only. For more information, see https://github.com/bpmn-io/bpmn-js/issues/1472';
13
14/**
15 * @private
16 *
17 * @param {ModdleElement} businessObject
18 */
19export function ensureCompatDiRef(businessObject) {
20
21 // bpmnElement can have multiple independent DIs
22 if (!has(businessObject, 'di')) {
23 Object.defineProperty(businessObject, 'di', {
24 enumerable: false,
25 get: function() {
26 throw new Error(DI_ERROR_MESSAGE);
27 }
28 });
29 }
30}
\No newline at end of file