@@ -18122,9 +18122,10 @@ def startSVGElementHandler(name, attribs, clipping = false)
18122
18122
@svggradients[@svggradientid]['gradientTransform'] = getSVGTransformMatrix(attribs['gradientTransform'])
18123
18123
end
18124
18124
@svggradients[@svggradientid]['coords'] = [x1, y1, x2, y2]
18125
- if attribs['xlink:href'] && !attribs['xlink:href'].empty?
18125
+ if (attribs['href'] && !attribs['href'].empty?) || (attribs['xlink:href'] && !attribs['xlink:href'].empty?)
18126
+ href = attribs['href'] ? 'href' : 'xlink:href'
18126
18127
# gradient is defined on another place
18127
- @svggradients[@svggradientid]['xref'] = attribs['xlink: href' ][1..-1]
18128
+ @svggradients[@svggradientid]['xref'] = attribs[href][1..-1]
18128
18129
end
18129
18130
when 'radialGradient'
18130
18131
@svggradientid = attribs['id']
@@ -18151,9 +18152,10 @@ def startSVGElementHandler(name, attribs, clipping = false)
18151
18152
@svggradients[@svggradientid]['gradientTransform'] = getSVGTransformMatrix(attribs['gradientTransform'])
18152
18153
end
18153
18154
@svggradients[@svggradientid]['coords'] = [cx, cy, fx, fy, r]
18154
- if attribs['xlink:href'] && !attribs['xlink:href'].empty?
18155
+ if (attribs['href'] && !attribs['href'].empty?) || (attribs['xlink:href'] && !attribs['xlink:href'].empty?)
18156
+ href = attribs['href'] ? 'href' : 'xlink:href'
18155
18157
# gradient is defined on another place
18156
- @svggradients[@svggradientid]['xref'] = attribs['xlink: href' ][1..-1]
18158
+ @svggradients[@svggradientid]['xref'] = attribs[href][1..-1]
18157
18159
end
18158
18160
when 'stop'
18159
18161
# gradient stops
@@ -18311,12 +18313,13 @@ def startSVGElementHandler(name, attribs, clipping = false)
18311
18313
end
18312
18314
end
18313
18315
when 'image' # image
18314
- if attribs['xlink:href'] && !attribs['xlink:href'].empty?
18316
+ if (attribs['href'] && !attribs['href'].empty?) || (attribs['xlink:href'] && !attribs['xlink:href'].empty?)
18317
+ href = attribs['href'] ? 'href' : 'xlink:href'
18315
18318
x = attribs['x'] ? getHTMLUnitToUnits(attribs['x'], 0, @svgunit, false) : 0
18316
18319
y = attribs['y'] ? getHTMLUnitToUnits(attribs['y'], 0, @svgunit, false) : 0
18317
18320
w = attribs['width'] ? getHTMLUnitToUnits(attribs['width'], 0, @svgunit, false) : 0
18318
18321
h = attribs['height'] ? getHTMLUnitToUnits(attribs['height'], 0, @svgunit, false) : 0
18319
- img = attribs['xlink: href' ]
18322
+ img = attribs[href]
18320
18323
unless clipping
18321
18324
start_transform()
18322
18325
svg_transform(tm)
@@ -18357,15 +18360,14 @@ def startSVGElementHandler(name, attribs, clipping = false)
18357
18360
set_xy(x, y, true)
18358
18361
@svgstyles.push(svgstyle)
18359
18362
when 'use' # use
18360
- if attribs['xlink:href']
18361
- use = @svgdefs[attribs['xlink:href'][1..-1]]
18362
- if attribs['xlink:href']
18363
- attribs.delete('xlink:href')
18364
- end
18365
- if use['id']
18366
- use.delete('id')
18367
- end
18368
- attribs = use['attribs'].merge(attribs)
18363
+ if attribs['href'] || attribs['xlink:href']
18364
+ href = attribs['href'] ? 'href' : 'xlink:href'
18365
+ use = @svgdefs[attribs[href][1..-1]]
18366
+ # Most attributes (except for x, y, width, height and (xlink:)href) do not override those set in the ancestor.
18367
+ ['x', 'y', 'width', 'height', 'hred', 'xlink:href'].each do |attr|
18368
+ use['attribs'].delete(attr) if attribs[attr]
18369
+ end
18370
+ attribs = attribs.merge(use['attribs'])
18369
18371
startSVGElementHandler(use['name'], use['attribs'])
18370
18372
end
18371
18373
end
0 commit comments