@@ -265,24 +265,24 @@ describe('svg+text utils', function() {
265
265
it ( 'supports superscript by itself' , function ( ) {
266
266
var node = mockTextSVGElement ( '<sup>123</sup>' ) ;
267
267
expect ( node . html ( ) ) . toBe (
268
- ' <tspan style="font-size:70%" dy="-0.6em">123</tspan>' +
269
- '<tspan dy="0.42em"> </tspan>' ) ;
268
+ '\u200b <tspan style="font-size:70%" dy="-0.6em">123</tspan>' +
269
+ '<tspan dy="0.42em">\u200b </tspan>' ) ;
270
270
} ) ;
271
271
272
272
it ( 'supports subscript by itself' , function ( ) {
273
273
var node = mockTextSVGElement ( '<sub>123</sub>' ) ;
274
274
expect ( node . html ( ) ) . toBe (
275
- ' <tspan style="font-size:70%" dy="0.3em">123</tspan>' +
276
- '<tspan dy="-0.21em"> </tspan>' ) ;
275
+ '\u200b <tspan style="font-size:70%" dy="0.3em">123</tspan>' +
276
+ '<tspan dy="-0.21em">\u200b </tspan>' ) ;
277
277
} ) ;
278
278
279
279
it ( 'supports superscript and subscript together with normal text' , function ( ) {
280
280
var node = mockTextSVGElement ( 'SO<sub>4</sub><sup>2-</sup>' ) ;
281
281
expect ( node . html ( ) ) . toBe (
282
- 'SO <tspan style="font-size:70%" dy="0.3em">4</tspan>' +
283
- '<tspan dy="-0.21em"> </tspan> ' +
282
+ 'SO\u200b <tspan style="font-size:70%" dy="0.3em">4</tspan>' +
283
+ '<tspan dy="-0.21em">\u200b </tspan>\u200b ' +
284
284
'<tspan style="font-size:70%" dy="-0.6em">2-</tspan>' +
285
- '<tspan dy="0.42em"> </tspan>' ) ;
285
+ '<tspan dy="0.42em">\u200b </tspan>' ) ;
286
286
} ) ;
287
287
288
288
it ( 'allows one <b> to span <br>s' , function ( ) {
@@ -300,12 +300,36 @@ describe('svg+text utils', function() {
300
300
it ( 'allows one <sub> to span <br>s' , function ( ) {
301
301
var node = mockTextSVGElement ( 'SO<sub>4<br>44</sub>' ) ;
302
302
expect ( node . html ( ) ) . toBe (
303
- '<tspan class="line" dy="0em">SO ' +
303
+ '<tspan class="line" dy="0em">SO\u200b ' +
304
304
'<tspan style="font-size:70%" dy="0.3em">4</tspan>' +
305
- '<tspan dy="-0.21em"> </tspan></tspan>' +
306
- '<tspan class="line" dy="1.3em"> ' +
305
+ '<tspan dy="-0.21em">\u200b </tspan></tspan>' +
306
+ '<tspan class="line" dy="1.3em">\u200b ' +
307
307
'<tspan style="font-size:70%" dy="0.3em">44</tspan>' +
308
- '<tspan dy="-0.21em"></tspan></tspan>' ) ;
308
+ '<tspan dy="-0.21em">\u200b</tspan></tspan>' ) ;
309
+ } ) ;
310
+
311
+ it ( 'allows nested tags to break at <br>, eventually closed or not' , function ( ) {
312
+ var textCases = [
313
+ '<b><i><sup>many<br>lines<br>modified' ,
314
+ '<b><i><sup>many<br>lines<br>modified</sup></i></b>' ,
315
+ '<b><i><sup>many</sup><br><sup>lines</sup></i><br><i><sup>modified' ,
316
+ ] ;
317
+
318
+ textCases . forEach ( function ( textCase ) {
319
+ var node = mockTextSVGElement ( textCase ) ;
320
+ function opener ( dy ) {
321
+ return '<tspan class="line" dy="' + dy + 'em">' +
322
+ '<tspan style="font-weight:bold">' +
323
+ '<tspan style="font-style:italic">' +
324
+ '\u200b<tspan style="font-size:70%" dy="-0.6em">' ;
325
+ }
326
+ var closer = '</tspan><tspan dy="0.42em">\u200b</tspan>' +
327
+ '</tspan></tspan></tspan>' ;
328
+ expect ( node . html ( ) ) . toBe (
329
+ opener ( 0 ) + 'many' + closer +
330
+ opener ( 1.3 ) + 'lines' + closer +
331
+ opener ( 2.6 ) + 'modified' + closer , textCase ) ;
332
+ } ) ;
309
333
} ) ;
310
334
} ) ;
311
335
} ) ;
0 commit comments