Skip to content

Commit

Permalink
fix: do not set colors on elements that don't support them
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme authored and nikku committed Feb 1, 2023
1 parent 7050af3 commit 588415c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/features/element-colors/ElementColors.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
getDi
getDi,
isAny
} from 'bpmn-js/lib/util/ModelUtil';


Expand Down Expand Up @@ -27,7 +28,7 @@ ElementColors.prototype.get = function(element) {
return {
stroke: di.label && di.label.get('color')
};
} else {
} else if (isAny(di, [ 'bpmndi:BPMNEdge', 'bpmndi:BPMNShape' ])) {
return {
fill: di.get('background-color'),
stroke: di.get('border-color')
Expand All @@ -52,7 +53,7 @@ ElementColors.prototype.set = function(element, colors) {
// BPMN-in-Color specification
if (isLabel(element)) {
di.label && di.label.set('color', stroke);
} else {
} else if (isAny(di, [ 'bpmndi:BPMNEdge', 'bpmndi:BPMNShape' ])) {
di.set('background-color', fill);
di.set('border-color', stroke);
}
Expand Down
14 changes: 14 additions & 0 deletions test/spec/ModelerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,20 @@ describe('modeler extension', function() {
}
));


it('should not set colors on elements that do not support them', inject(async function(bpmnjs, toggleMode) {

// when
toggleMode.toggleMode();

// then
const definitions = bpmnjs.getDefinitions(),
diagrams = definitions.get('diagrams'),
plane = diagrams[ 0 ].get('plane');

expect(plane.$attrs).to.be.empty;
}));

});


Expand Down
2 changes: 1 addition & 1 deletion test/spec/colors.bpmn
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<di:waypoint x="596" y="120" />
<di:waypoint x="646" y="120" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1x1ty9t_di" bpmnElement="SequenceFlow_2" bioc:stroke="#1e88e5" bioc:fill="#bbdefb" color:border-color="#1e88e5">
<bpmndi:BPMNEdge id="SequenceFlow_2_di" bpmnElement="SequenceFlow_2" bioc:stroke="#1e88e5" bioc:fill="#bbdefb" color:border-color="#1e88e5">
<di:waypoint x="421" y="211" />
<di:waypoint x="421" y="120" />
<di:waypoint x="496" y="120" />
Expand Down

0 comments on commit 588415c

Please sign in to comment.