@@ -18139,9 +18139,10 @@ def startSVGElementHandler(name, attribs, clipping = false)
18139
18139
@svggradients[@svggradientid]['gradientTransform'] = getSVGTransformMatrix(attribs['gradientTransform'])
18140
18140
end
18141
18141
@svggradients[@svggradientid]['coords'] = [x1, y1, x2, y2]
18142
- if attribs['xlink:href'] && !attribs['xlink:href'].empty?
18142
+ if (attribs['href'] && !attribs['href'].empty?) || (attribs['xlink:href'] && !attribs['xlink:href'].empty?)
18143
+ href = attribs['href'] ? 'href' : 'xlink:href'
18143
18144
# gradient is defined on another place
18144
- @svggradients[@svggradientid]['xref'] = attribs['xlink: href' ][1..-1]
18145
+ @svggradients[@svggradientid]['xref'] = attribs[href][1..-1]
18145
18146
end
18146
18147
when 'radialGradient'
18147
18148
@svggradientid = attribs['id']
@@ -18168,9 +18169,10 @@ def startSVGElementHandler(name, attribs, clipping = false)
18168
18169
@svggradients[@svggradientid]['gradientTransform'] = getSVGTransformMatrix(attribs['gradientTransform'])
18169
18170
end
18170
18171
@svggradients[@svggradientid]['coords'] = [cx, cy, fx, fy, r]
18171
- if attribs['xlink:href'] && !attribs['xlink:href'].empty?
18172
+ if (attribs['href'] && !attribs['href'].empty?) || (attribs['xlink:href'] && !attribs['xlink:href'].empty?)
18173
+ href = attribs['href'] ? 'href' : 'xlink:href'
18172
18174
# gradient is defined on another place
18173
- @svggradients[@svggradientid]['xref'] = attribs['xlink: href' ][1..-1]
18175
+ @svggradients[@svggradientid]['xref'] = attribs[href][1..-1]
18174
18176
end
18175
18177
when 'stop'
18176
18178
# gradient stops
@@ -18328,12 +18330,13 @@ def startSVGElementHandler(name, attribs, clipping = false)
18328
18330
end
18329
18331
end
18330
18332
when 'image' # image
18331
- if attribs['xlink:href'] && !attribs['xlink:href'].empty?
18333
+ if (attribs['href'] && !attribs['href'].empty?) || (attribs['xlink:href'] && !attribs['xlink:href'].empty?)
18334
+ href = attribs['href'] ? 'href' : 'xlink:href'
18332
18335
x = attribs['x'] ? getHTMLUnitToUnits(attribs['x'], 0, @svgunit, false) : 0
18333
18336
y = attribs['y'] ? getHTMLUnitToUnits(attribs['y'], 0, @svgunit, false) : 0
18334
18337
w = attribs['width'] ? getHTMLUnitToUnits(attribs['width'], 0, @svgunit, false) : 0
18335
18338
h = attribs['height'] ? getHTMLUnitToUnits(attribs['height'], 0, @svgunit, false) : 0
18336
- img = attribs['xlink: href' ]
18339
+ img = attribs[href]
18337
18340
unless clipping
18338
18341
start_transform()
18339
18342
svg_transform(tm)
@@ -18374,15 +18377,14 @@ def startSVGElementHandler(name, attribs, clipping = false)
18374
18377
set_xy(x, y, true)
18375
18378
@svgstyles.push(svgstyle)
18376
18379
when 'use' # use
18377
- if attribs['xlink:href']
18378
- use = @svgdefs[attribs['xlink:href'][1..-1]]
18379
- if attribs['xlink:href']
18380
- attribs.delete('xlink:href')
18381
- end
18382
- if use['id']
18383
- use.delete('id')
18384
- end
18385
- attribs = use['attribs'].merge(attribs)
18380
+ if attribs['href'] || attribs['xlink:href']
18381
+ href = attribs['href'] ? 'href' : 'xlink:href'
18382
+ use = @svgdefs[attribs[href][1..-1]]
18383
+ # Most attributes (except for x, y, width, height and (xlink:)href) do not override those set in the ancestor.
18384
+ ['x', 'y', 'width', 'height', 'hred', 'xlink:href'].each do |attr|
18385
+ use['attribs'].delete(attr) if attribs[attr]
18386
+ end
18387
+ attribs = attribs.merge(use['attribs'])
18386
18388
startSVGElementHandler(use['name'], use['attribs'])
18387
18389
end
18388
18390
end
0 commit comments