fix(BpmnTreeWalker): do not fail if no di

This commit is contained in:
Nico Rehwaldt 2014-03-17 11:11:25 +01:00
parent 60b27e393f
commit 1d46d915d1
2 changed files with 20 additions and 2 deletions

View File

@ -14,7 +14,7 @@ function BpmnTraverser(visitor) {
}
function is(element, type) {
return element.__isInstanceOf(type);
return element.__instanceOf(type);
}
function visit(element, di, ctx) {
@ -82,7 +82,14 @@ function BpmnTraverser(visitor) {
}
if (!diagram) {
diagram = diagrams[0];
if (diagrams && diagrams.length) {
diagram = diagrams[0];
}
}
// no diagram -> nothing to import
if (!diagram) {
return;
}
var rootElement = diagram.plane.bpmnElement;

View File

@ -36,4 +36,15 @@ describe('Importer', function() {
diagram.importDefinitions(result, done);
});
});
it('should import empty definitions', function(done) {
var xml = fs.readFileSync('test/fixtures/bpmn/empty-definitions.bpmn', 'utf8');
read(xml, function(err, result) {
var diagram = new Diagram(container);
diagram.importDefinitions(result, done);
});
});
});