feat(test): expose BpmnJS set and clear utilities

This commit is contained in:
Nico Rehwaldt 2019-07-19 13:48:28 +02:00 committed by fake-join[bot]
parent a86b1476dd
commit 991ab38c3d
1 changed files with 18 additions and 6 deletions

View File

@ -112,14 +112,13 @@ export function bootstrapBpmnJS(BpmnJS, diagram, options, locals) {
); );
} }
// clean up old bpmn-js instance clearBpmnJS();
if (BPMN_JS) {
BPMN_JS.destroy();
}
BPMN_JS = new BpmnJS(_options); var instance = new BpmnJS(_options);
BPMN_JS.importXML(diagram, done); setBpmnJS(instance);
instance.importXML(diagram, done);
}; };
} }
@ -227,6 +226,19 @@ export function getBpmnJS() {
return BPMN_JS; return BPMN_JS;
} }
export function clearBpmnJS() {
// clean up old bpmn-js instance
if (BPMN_JS) {
BPMN_JS.destroy();
BPMN_JS = null;
}
}
export function setBpmnJS(instance) {
BPMN_JS = instance;
}
export function insertCSS(name, css) { export function insertCSS(name, css) {
if (document.querySelector('[data-css-file="' + name + '"]')) { if (document.querySelector('[data-css-file="' + name + '"]')) {