chore: throw error when accessing DI from business object

Related to https://github.com/bpmn-io/bpmn-js/issues/1472
This commit is contained in:
Martin Stamm
2021-08-25 14:49:00 +02:00
committed by Nico Rehwaldt
parent 0c40cbe9f3
commit 597c417dce
7 changed files with 95 additions and 5 deletions

View File

@ -1,4 +1,7 @@
import { isFunction } from 'min-dash';
import {
has,
isFunction
} from 'min-dash';
// TODO(nikku): remove with future bpmn-js version
@ -51,3 +54,20 @@ export function wrapForCompatibility(api) {
}
};
}
// TODO(nikku): remove with future bpmn-js version
var 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';
export function ensureCompatDiRef(businessObject) {
// bpmnElement can have multiple independent DIs
if (!has(businessObject, 'di')) {
Object.defineProperty(businessObject, 'di', {
get: function() {
throw new Error(DI_ERROR_MESSAGE);
}
});
}
}