fix(Viewer): correctly export SVG

Use upstream patch of tiny-svg to address this.

Closes #631
This commit is contained in:
Nico Rehwaldt 2016-11-17 18:22:54 +01:00 committed by Ricardo Matias
parent 4d01cebe76
commit a2d7140cdf
2 changed files with 14 additions and 5 deletions

View File

@ -80,6 +80,6 @@
"lodash": "^3.0.1", "lodash": "^3.0.1",
"min-dom": "^0.2.0", "min-dom": "^0.2.0",
"object-refs": "^0.1.1", "object-refs": "^0.1.1",
"tiny-svg": "^0.1.0" "tiny-svg": "^0.1.1"
} }
} }

View File

@ -317,7 +317,7 @@ describe('Viewer', function() {
return new Date().getTime(); return new Date().getTime();
} }
function isValid(svg) { function validSVG(svg) {
var expectedStart = '<?xml version="1.0" encoding="utf-8"?>'; var expectedStart = '<?xml version="1.0" encoding="utf-8"?>';
var expectedEnd = '</svg>'; var expectedEnd = '</svg>';
@ -331,6 +331,15 @@ describe('Viewer', function() {
expect(svg.indexOf('<svg width="100%" height="100%">')).to.equal(-1); expect(svg.indexOf('<svg width="100%" height="100%">')).to.equal(-1);
expect(svg.indexOf('<g class="viewport"')).to.equal(-1); expect(svg.indexOf('<g class="viewport"')).to.equal(-1);
var parser = new DOMParser();
var svgNode = parser.parseFromString(svg, 'image/svg+xml');
// [comment, <!DOCTYPE svg>, svg]
expect(svgNode.childNodes).to.have.length(3);
// no error body
expect(svgNode.body).not.to.exist;
// FIXME(nre): make matcher // FIXME(nre): make matcher
return true; return true;
} }
@ -385,7 +394,7 @@ describe('Viewer', function() {
} }
// then // then
expect(isValid(svg)).to.be.true; expect(validSVG(svg)).to.be.true;
done(); done();
}); });
@ -416,7 +425,7 @@ describe('Viewer', function() {
} }
// then // then
expect(isValid(svg)).to.be.true; expect(validSVG(svg)).to.be.true;
// no svg export should not take too long // no svg export should not take too long
expect(currentTime() - time).to.be.below(1000); expect(currentTime() - time).to.be.below(1000);
@ -467,7 +476,7 @@ describe('Viewer', function() {
svgDoc.innerHTML = svg; svgDoc.innerHTML = svg;
// then // then
expect(isValid(svg)).to.be.true; expect(validSVG(svg)).to.be.true;
expect(svgDoc.querySelector('.outer-bound-marker')).to.be.null; expect(svgDoc.querySelector('.outer-bound-marker')).to.be.null;
done(); done();