@@ -150,7 +150,8 @@ describe('Plotly.Snapshot', function() {
150
150
} ) ;
151
151
152
152
describe ( 'toSVG' , function ( ) {
153
- var gd ;
153
+ var parser = new DOMParser ( ) ,
154
+ gd ;
154
155
155
156
beforeEach ( function ( ) {
156
157
gd = createGraphDiv ( ) ;
@@ -163,19 +164,21 @@ describe('Plotly.Snapshot', function() {
163
164
Plotly . plot ( gd , subplotMock . data , subplotMock . layout ) . then ( function ( ) {
164
165
return Plotly . Snapshot . toSVG ( gd ) ;
165
166
} ) . then ( function ( svg ) {
166
- var splitSVG = svg . split ( '<svg' ) ;
167
+ var svgDOM = parser . parseFromString ( svg , 'image/svg+xml' ) ,
168
+ svgElements = svgDOM . getElementsByTagName ( 'svg' ) ;
167
169
168
- expect ( splitSVG . length ) . toBe ( 2 ) ;
170
+ expect ( svgElements . length ) . toBe ( 1 ) ;
169
171
} ) . then ( done ) ;
170
172
} ) ;
171
173
172
174
it ( 'should not return any nested svg tags of annotations' , function ( done ) {
173
175
Plotly . plot ( gd , annotationMock . data , annotationMock . layout ) . then ( function ( ) {
174
176
return Plotly . Snapshot . toSVG ( gd ) ;
175
177
} ) . then ( function ( svg ) {
176
- var splitSVG = svg . split ( '<svg' ) ;
178
+ var svgDOM = parser . parseFromString ( svg , 'image/svg+xml' ) ,
179
+ svgElements = svgDOM . getElementsByTagName ( 'svg' ) ;
177
180
178
- expect ( splitSVG . length ) . toBe ( 2 ) ;
181
+ expect ( svgElements . length ) . toBe ( 1 ) ;
179
182
} ) . then ( done ) ;
180
183
} ) ;
181
184
} ) ;
0 commit comments