chore(draw): expose extension points
+ clearly documented as *UNSAFE* + add test cases + tested existing *UNSAFE* handler endpoint
This commit is contained in:
parent
50ed07966f
commit
e0a2b4164d
|
@ -382,16 +382,16 @@ export default function BpmnRenderer(
|
|||
return drawPath(parentGfx, path, assign({ 'data-marker': type }, attrs));
|
||||
}
|
||||
|
||||
function as(type) {
|
||||
return function(parentGfx, element) {
|
||||
return handlers[type](parentGfx, element);
|
||||
};
|
||||
}
|
||||
|
||||
function renderer(type) {
|
||||
return handlers[type];
|
||||
}
|
||||
|
||||
function as(type) {
|
||||
return function(parentGfx, element) {
|
||||
return renderer(type)(parentGfx, element);
|
||||
};
|
||||
}
|
||||
|
||||
function renderEventContent(element, parentGfx) {
|
||||
|
||||
var event = getSemantic(element);
|
||||
|
@ -1872,6 +1872,7 @@ export default function BpmnRenderer(
|
|||
// extension API, use at your own risk
|
||||
this._drawPath = drawPath;
|
||||
|
||||
this._renderer = renderer;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1893,7 +1894,7 @@ BpmnRenderer.prototype.canRender = function(element) {
|
|||
|
||||
BpmnRenderer.prototype.drawShape = function(parentGfx, element) {
|
||||
var type = element.type;
|
||||
var h = this.handlers[type];
|
||||
var h = this._renderer(type);
|
||||
|
||||
/* jshint -W040 */
|
||||
return h(parentGfx, element);
|
||||
|
@ -1901,7 +1902,7 @@ BpmnRenderer.prototype.drawShape = function(parentGfx, element) {
|
|||
|
||||
BpmnRenderer.prototype.drawConnection = function(parentGfx, element) {
|
||||
var type = element.type;
|
||||
var h = this.handlers[type];
|
||||
var h = this._renderer(type);
|
||||
|
||||
/* jshint -W040 */
|
||||
return h(parentGfx, element);
|
||||
|
|
|
@ -671,8 +671,13 @@ describe('draw - bpmn renderer', function() {
|
|||
it('should expose helpers', inject(function(bpmnRenderer) {
|
||||
|
||||
// then
|
||||
expect(bpmnRenderer._drawPath).to.be.a('function');
|
||||
|
||||
// unsafe to use render APIs
|
||||
expect(bpmnRenderer._drawPath).to.be.a('function');
|
||||
expect(bpmnRenderer._renderer).to.be.a('function');
|
||||
|
||||
// very unsafe to use internal state
|
||||
expect(bpmnRenderer.handlers).to.exist;
|
||||
}));
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue