chore(import): don't monkey patch ID but use `attrs` utility

This commit is contained in:
Nico Rehwaldt 2021-11-03 11:41:31 +01:00 committed by Nico Rehwaldt
parent f2b47e17f3
commit e9cf046bbb
1 changed files with 12 additions and 6 deletions

View File

@ -26,6 +26,13 @@ import {
} from './Util'; } from './Util';
/**
* @param {ModdleElement} semantic
* @param {ModdleElement} di
* @param {Object} [attrs=null]
*
* @return {Object}
*/
function elementData(semantic, di, attrs) { function elementData(semantic, di, attrs) {
return assign({ return assign({
id: semantic.id, id: semantic.id,
@ -105,13 +112,12 @@ BpmnImporter.prototype.add = function(semantic, di, parentElement) {
// invisible root element (process, subprocess or collaboration) // invisible root element (process, subprocess or collaboration)
if (is(di, 'bpmndi:BPMNPlane')) { if (is(di, 'bpmndi:BPMNPlane')) {
// add a virtual element (not being drawn) var attrs = is(semantic, 'bpmn:SubProcess')
element = this._elementFactory.createRoot(elementData(semantic, di)); ? { id: semantic.id + '_plane' }
: {};
// for subprocesses, the id is already defined on the collapsed shape // add a virtual element (not being drawn)
if (is(semantic, 'bpmn:SubProcess')) { element = this._elementFactory.createRoot(elementData(semantic, di, attrs));
element.id = element.id + '_plane';
}
this._canvas.addRootElement(element); this._canvas.addRootElement(element);
} }