diff --git a/lib/BpmnTreeWalker.js b/lib/BpmnTreeWalker.js index dcd1bbcf..4d635837 100644 --- a/lib/BpmnTreeWalker.js +++ b/lib/BpmnTreeWalker.js @@ -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; diff --git a/test/spec/browser/ImporterSpec.js b/test/spec/browser/ImporterSpec.js index b33a40dd..c7b82496 100644 --- a/test/spec/browser/ImporterSpec.js +++ b/test/spec/browser/ImporterSpec.js @@ -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); + }); + }); }); \ No newline at end of file