CompatibilityUtil.js 729 B

123456789101112131415161718192021222324252627282930
  1. import {
  2. has
  3. } from 'min-dash';
  4. /**
  5. * @typedef {import('../model/Types').ModdleElement} ModdleElement
  6. */
  7. // TODO(nikku): remove with future bpmn-js version
  8. 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';
  9. /**
  10. * @private
  11. *
  12. * @param {ModdleElement} businessObject
  13. */
  14. export function ensureCompatDiRef(businessObject) {
  15. // bpmnElement can have multiple independent DIs
  16. if (!has(businessObject, 'di')) {
  17. Object.defineProperty(businessObject, 'di', {
  18. enumerable: false,
  19. get: function() {
  20. throw new Error(DI_ERROR_MESSAGE);
  21. }
  22. });
  23. }
  24. }