@@ -94,8 +94,11 @@ util.convertToTspans = function(_context, _callback) {
94
94
visibility : 'visible' ,
95
95
'white-space' : 'pre'
96
96
} ) ;
97
+
97
98
result = _context . appendSVG ( converted ) ;
99
+
98
100
if ( ! result ) _context . text ( str ) ;
101
+
99
102
if ( _context . select ( 'a' ) . size ( ) ) {
100
103
// at least in Chrome, pointer-events does not seem
101
104
// to be honored in children of <text> elements
@@ -245,6 +248,7 @@ function convertToSVG(_str) {
245
248
var match = d . match ( / < ( \/ ? ) ( [ ^ > ] * ) \s * ( .* ) > / i) ,
246
249
tag = match && match [ 2 ] . toLowerCase ( ) ,
247
250
style = TAG_STYLES [ tag ] ;
251
+
248
252
if ( style !== undefined ) {
249
253
var close = match [ 1 ] ,
250
254
extra = match [ 3 ] ,
@@ -262,12 +266,18 @@ function convertToSVG(_str) {
262
266
if ( close ) return '</a>' ;
263
267
else if ( extra . substr ( 0 , 4 ) . toLowerCase ( ) !== 'href' ) return '<a>' ;
264
268
else {
265
- var dummyAnchor = document . createElement ( 'a' ) ;
266
- dummyAnchor . href = extra . substr ( 4 ) . replace ( / [ " ' = ] / g, '' ) ;
269
+ // remove quotes, leading '=', replace '&' with '&'
270
+ var href = extra . substr ( 4 )
271
+ . replace ( / [ " ' ] / g, '' )
272
+ . replace ( / = / , '' )
273
+ . replace ( / & / g, '&' ) ;
267
274
275
+ // check protocol
276
+ var dummyAnchor = document . createElement ( 'a' ) ;
277
+ dummyAnchor . href = href ;
268
278
if ( PROTOCOLS . indexOf ( dummyAnchor . protocol ) === - 1 ) return '<a>' ;
269
279
270
- return '<a xlink:show="new" xlink:href' + extra . substr ( 4 ) + '>' ;
280
+ return '<a xlink:show="new" xlink:href=" ' + href + '" >' ;
271
281
}
272
282
}
273
283
else if ( tag === 'br' ) return '<br>' ;
0 commit comments