Skip to content

Nested <svg> removal #415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 13, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions test/jasmine/tests/snapshot_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ describe('Plotly.Snapshot', function() {
});

describe('toSVG', function() {
var gd;
var parser = new DOMParser(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍻

gd;

beforeEach(function() {
gd = createGraphDiv();
Expand All @@ -163,19 +164,21 @@ describe('Plotly.Snapshot', function() {
Plotly.plot(gd, subplotMock.data, subplotMock.layout).then(function() {
return Plotly.Snapshot.toSVG(gd);
}).then(function(svg) {
var splitSVG = svg.split('<svg');
var svgDOM = parser.parseFromString(svg, 'image/svg+xml'),
svgElements = svgDOM.getElementsByTagName('svg');

expect(splitSVG.length).toBe(2);
expect(svgElements.length).toBe(1);
}).then(done);
});

it('should not return any nested svg tags of annotations', function(done) {
Plotly.plot(gd, annotationMock.data, annotationMock.layout).then(function() {
return Plotly.Snapshot.toSVG(gd);
}).then(function(svg) {
var splitSVG = svg.split('<svg');
var svgDOM = parser.parseFromString(svg, 'image/svg+xml'),
svgElements = svgDOM.getElementsByTagName('svg');

expect(splitSVG.length).toBe(2);
expect(svgElements.length).toBe(1);
}).then(done);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nicely done 🎉

});
});
Expand Down