Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken reimport #166

Merged
merged 5 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/Modeler.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import SwitchModule from './features/switch';
import BpmnDiOrdering from './features/di-ordering';

import {
displayChoreography
displayChoreography,
clearShapeCache
} from './import/ImportHandler';


Expand All @@ -38,6 +39,11 @@ Modeler.prototype.open = function(bpmnDiagramOrId) {
return displayChoreography(this, bpmnDiagramOrId);
};

Modeler.prototype.importXML = function(xml, bpmnDiagram) {
clearShapeCache();
return BaseModeler.prototype.importXML.call(this, xml, bpmnDiagram);
};

Modeler.prototype.clear = function() {
// Skip clearing of the DI references introduced in this commit by bpmn-js:
// https://github.com/bpmn-io/bpmn-js/commit/0c71ad30a0c945679851e73b15647f634f2b9bb8
Expand Down
8 changes: 7 additions & 1 deletion lib/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import inherits from 'inherits';
import CoreModule from './core';

import {
displayChoreography
displayChoreography,
clearShapeCache
} from './import/ImportHandler';


Expand Down Expand Up @@ -35,6 +36,11 @@ Viewer.prototype.open = function(bpmnDiagramOrId) {
return displayChoreography(this, bpmnDiagramOrId);
};

Viewer.prototype.importXML = function(xml, bpmnDiagram) {
clearShapeCache();
return BaseViewer.prototype.importXML.call(this, xml, bpmnDiagram);
};

Viewer.prototype.clear = function() {
// Skip clearing of the DI references introduced in this commit by bpmn-js:
// https://github.com/bpmn-io/bpmn-js/commit/0c71ad30a0c945679851e73b15647f634f2b9bb8
Expand Down
8 changes: 8 additions & 0 deletions lib/import/ImportHandler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
let shapeCache = {};

/**
* Clear the cached shapes. This function should be called when loading a new diagram,
* since the old cache might lead to errors if elements with the same IDs are encountered.
*/
export function clearShapeCache() {
shapeCache = {};
}

/**
* Display a specific choreography contained in the definitions attached to a viewer.
*
Expand Down