Skip to content

Commit

Permalink
fix: pass attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Mar 20, 2024
1 parent 3cecb18 commit f8b6129
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/ElementTemplateIconRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ElementTemplateIconRenderer.prototype._getIcon = function(element) {
return getModelerTemplateIcon(element, this._iconProperty);
};

ElementTemplateIconRenderer.prototype.drawShape = function(parentGfx, element) {
ElementTemplateIconRenderer.prototype.drawShape = function(parentGfx, element, attrs = {}) {

var renderer = this._bpmnRenderer.handlers[
[
Expand All @@ -68,7 +68,7 @@ ElementTemplateIconRenderer.prototype.drawShape = function(parentGfx, element) {
].find(t => is(element, t))
];

var gfx = renderer(parentGfx, element, { renderIcon: false });
var gfx = renderer(parentGfx, element, { ...attrs, renderIcon: false });

var icon = this._getIcon(element);

Expand Down
25 changes: 24 additions & 1 deletion test/spec/ElementTemplateIconRenderer.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import TestContainer from 'mocha-test-container-support';
import TestContainer, { get } from 'mocha-test-container-support';

Check failure on line 1 in test/spec/ElementTemplateIconRenderer.spec.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 16)

'get' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 1 in test/spec/ElementTemplateIconRenderer.spec.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 16)

'get' is defined but never used. Allowed unused vars must match /^_/u

import BpmnViewer from 'bpmn-js/lib/Viewer';

Expand Down Expand Up @@ -330,6 +330,29 @@ describe('elementTemplateIconRenderer', function() {
expect(iconGfx).to.not.exist;
}));


it.only('should pass attrs', inject(function(elementRegistry, eventBus, graphicsFactory) {

Check failure on line 334 in test/spec/ElementTemplateIconRenderer.spec.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 16)

Unexpected exclusive mocha test

Check failure on line 334 in test/spec/ElementTemplateIconRenderer.spec.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 16)

Unexpected exclusive mocha test

// given
const element = elementRegistry.get('SendGridTask'),
gfx = elementRegistry.getGraphics(element);

eventBus.on([ 'render.shape', 'render.connection' ], (event, context) => {
context.attrs = {
...context.attrs,
stroke: 'rgb(34, 36, 42)'
};
});

// when
graphicsFactory.update('shape', element, gfx);

// then
console.log(getVisuals(gfx));
expect(getVisuals(gfx)).to.exist;
expect(svgAttr(getVisuals(gfx).firstChild, 'stroke')).to.eql('rgb(34, 36, 42)');
}));

});

});
Expand Down

0 comments on commit f8b6129

Please sign in to comment.