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