From 27d65a6503aea40910a7a1fb7b6946a0c55e8a7a Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Tue, 20 Dec 2016 16:54:45 +0100 Subject: [PATCH] fix(draw): do not create multiple markers per (type-stoke-fill) --- lib/draw/BpmnRenderer.js | 5 ++--- test/spec/draw/BpmnRendererSpec.js | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/draw/BpmnRenderer.js b/lib/draw/BpmnRenderer.js index 6eb5f138..362e2092 100644 --- a/lib/draw/BpmnRenderer.js +++ b/lib/draw/BpmnRenderer.js @@ -5,7 +5,6 @@ var inherits = require('inherits'), assign = require('lodash/object/assign'), forEach = require('lodash/collection/forEach'), every = require('lodash/collection/every'), - includes = require('lodash/collection/includes'), some = require('lodash/collection/some'); var BaseRenderer = require('diagram-js/lib/draw/BaseRenderer'), @@ -103,7 +102,7 @@ function BpmnRenderer(eventBus, styles, pathMap, canvas, priority) { function marker(type, fill, stroke) { var id = type + '-' + fill + '-' + stroke; - if (!includes(markers, id)) { + if (!markers[id]) { createMarker(type, fill, stroke); } @@ -1701,7 +1700,7 @@ function BpmnRenderer(eventBus, styles, pathMap, canvas, priority) { function attachTaskMarkers(parentGfx, element, taskMarkers) { var obj = getSemantic(element); - var subprocess = includes(taskMarkers, 'SubProcessMarker'); + var subprocess = taskMarkers && taskMarkers.indexOf('SubProcessMarker') !== -1; var position; if (subprocess) { diff --git a/test/spec/draw/BpmnRendererSpec.js b/test/spec/draw/BpmnRendererSpec.js index 6436512a..ebad0a4b 100644 --- a/test/spec/draw/BpmnRendererSpec.js +++ b/test/spec/draw/BpmnRendererSpec.js @@ -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() { var diagramXML = require('../../fixtures/bpmn/simple-cropping.bpmn');