diff --git a/lib/features/modeling/cmd/UpdatePropertiesHandler.js b/lib/features/modeling/cmd/UpdatePropertiesHandler.js index d7a7761c..6749e022 100644 --- a/lib/features/modeling/cmd/UpdatePropertiesHandler.js +++ b/lib/features/modeling/cmd/UpdatePropertiesHandler.js @@ -98,10 +98,6 @@ UpdatePropertiesHandler.prototype.execute = function(context) { element.label.hidden = !properties[NAME]; } - if (DI in properties && businessObject.di) { - setDiProperties(businessObject.di, properties.di); - } - // update properties setProperties(businessObject, properties); @@ -147,10 +143,6 @@ UpdatePropertiesHandler.prototype.revert = function(context) { elementRegistry = this._elementRegistry, ids = this._moddle.ids; - if (DI in oldProperties && businessObject.di) { - setDiProperties(businessObject.di, oldProperties.di); - } - // update properties setProperties(businessObject, oldProperties); @@ -199,7 +191,15 @@ function getDiProperties(di, propertyNames) { function setProperties(businessObject, properties) { forEach(properties, function(value, key) { - businessObject.set(key, value); + + if (key !== DI) { + businessObject.set(key, value); + } else { + // only update, if businessObject.id exists + if (businessObject.di) { + setDiProperties(businessObject.di, value); + } + } }); } diff --git a/test/spec/features/modeling/UpdatePropertiesSpec.js b/test/spec/features/modeling/UpdatePropertiesSpec.js index 267ef65b..20b1a49f 100644 --- a/test/spec/features/modeling/UpdatePropertiesSpec.js +++ b/test/spec/features/modeling/UpdatePropertiesSpec.js @@ -270,6 +270,8 @@ describe('features/modeling - update properties', function() { // then expect(flowBo.di.fill).to.equal('FUCHSIA'); + + expect(flowBo.get('di')).not.to.exist; })); @@ -578,6 +580,25 @@ describe('features/modeling - update properties', function() { } )); + + it('should ignore setting color on root', inject( + function(canvas, modeling) { + + // given + var rootElement = canvas.getRootElement(); + + // when + modeling.updateProperties(rootElement, { + di: { + fill: 'fuchsia' + } + }); + + // then + expect(rootElement.di).not.to.exist; + } + )); + }); });