fix(moddle-copy): properly copy ids

Related to https://github.com/camunda/camunda-modeler/issues/1410
This commit is contained in:
Maciej Barelkowski 2021-10-20 11:17:52 +02:00 committed by Maciej Barelkowski
parent 97e1ad14ba
commit 39d7b9e59b
1 changed files with 15 additions and 3 deletions

View File

@ -220,9 +220,9 @@ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName) {
return; return;
} }
// disallow copying IDs if already assigned // copy id
if (propertyDescriptor.isId && this._moddle.ids.assigned(property)) { if (propertyDescriptor.isId) {
return; return this._copyId(property, parent);
} }
// copy arrays // copy arrays
@ -263,6 +263,18 @@ ModdleCopy.prototype.copyProperty = function(property, parent, propertyName) {
return property; return property;
}; };
ModdleCopy.prototype._copyId = function(id, element) {
// disallow if already taken
if (this._moddle.ids.assigned(id)) {
return;
} else {
this._moddle.ids.claim(id, element);
return id;
}
};
// helpers ////////// // helpers //////////
export function getPropertyNames(descriptor, keepDefaultProperties) { export function getPropertyNames(descriptor, keepDefaultProperties) {