fix(draw): do not create multiple markers per (type-stoke-fill)

This commit is contained in:
Nico Rehwaldt 2016-12-20 16:54:45 +01:00
parent e2211766eb
commit 27d65a6503
2 changed files with 23 additions and 3 deletions

View File

@ -5,7 +5,6 @@ var inherits = require('inherits'),
assign = require('lodash/object/assign'), assign = require('lodash/object/assign'),
forEach = require('lodash/collection/forEach'), forEach = require('lodash/collection/forEach'),
every = require('lodash/collection/every'), every = require('lodash/collection/every'),
includes = require('lodash/collection/includes'),
some = require('lodash/collection/some'); some = require('lodash/collection/some');
var BaseRenderer = require('diagram-js/lib/draw/BaseRenderer'), var BaseRenderer = require('diagram-js/lib/draw/BaseRenderer'),
@ -103,7 +102,7 @@ function BpmnRenderer(eventBus, styles, pathMap, canvas, priority) {
function marker(type, fill, stroke) { function marker(type, fill, stroke) {
var id = type + '-' + fill + '-' + stroke; var id = type + '-' + fill + '-' + stroke;
if (!includes(markers, id)) { if (!markers[id]) {
createMarker(type, fill, stroke); createMarker(type, fill, stroke);
} }
@ -1701,7 +1700,7 @@ function BpmnRenderer(eventBus, styles, pathMap, canvas, priority) {
function attachTaskMarkers(parentGfx, element, taskMarkers) { function attachTaskMarkers(parentGfx, element, taskMarkers) {
var obj = getSemantic(element); var obj = getSemantic(element);
var subprocess = includes(taskMarkers, 'SubProcessMarker'); var subprocess = taskMarkers && taskMarkers.indexOf('SubProcessMarker') !== -1;
var position; var position;
if (subprocess) { if (subprocess) {

View File

@ -221,6 +221,27 @@ describe('draw - bpmn renderer', function() {
}); });
it('should properly render colored markers', function(done) {
var xml = require('../../fixtures/bpmn/draw/colors.bpmn');
bootstrapViewer(xml)(function(err) {
if (err) {
return done(err);
}
inject(function(canvas) {
var svg = canvas._svg;
var markers = svg.querySelectorAll('marker');
expect(markers).to.have.length(5);
})();
done();
});
});
describe('path', function() { describe('path', function() {
var diagramXML = require('../../fixtures/bpmn/simple-cropping.bpmn'); var diagramXML = require('../../fixtures/bpmn/simple-cropping.bpmn');