diff --git a/lib/Viewer.js b/lib/Viewer.js index 70576c47..689c9c9a 100644 --- a/lib/Viewer.js +++ b/lib/Viewer.js @@ -21,7 +21,7 @@ function getSvgContents(diagram) { var outerNode = paper.node.parentNode; var svg = outerNode.innerHTML; - return svg.replace(/^]>|<\/svg>$/, ''); + return svg.replace(/^]*>|<\/svg>$/g, ''); } function initListeners(diagram, listeners) { @@ -123,9 +123,8 @@ Viewer.prototype.saveXML = function(options, done) { var SVG_HEADER = '\n' + '\n' + -'\n' + -'\n'; +'\n' + +'\n'; var SVG_FOOTER = ''; diff --git a/test/spec/browser/ViewerSpec.js b/test/spec/browser/ViewerSpec.js index e1d26721..d1a1a6bf 100644 --- a/test/spec/browser/ViewerSpec.js +++ b/test/spec/browser/ViewerSpec.js @@ -107,6 +107,9 @@ describe('Viewer', function() { // ensure correct rendering of SVG contents expect(svg.indexOf('undefined')).toBe(-1); + // expect header to be written only once + expect(svg.indexOf('')).toBe(-1); + done(); }); });