Also cover quoted forms of url(#grad) for removing duplicate gradients

This commit is contained in:
Jeff Schiller 2009-08-01 10:48:55 -05:00
parent 37cfec8098
commit 9ade298cd6
2 changed files with 5 additions and 4 deletions

View file

@ -759,7 +759,8 @@ def removeDuplicateGradients(doc):
# find out which attribute referenced the duplicate gradient
for attr in ['fill', 'stroke']:
# TODO: also need to check for url("#id")
if elem.getAttribute(attr) == 'url(#'+dup_id+')':
v = elem.getAttribute(attr)
if v == 'url(#'+dup_id+')' or v == 'url("#'+dup_id+'")' or v == "url('#"+dup_id+"')":
elem.setAttribute(attr, 'url(#'+master_id+')')
if elem.getAttributeNS(NS['XLINK'], 'href') == '#'+dup_id:
elem.setAttributeNS(NS['XLINK'], 'href', '#'+master_id)

View file

@ -12,7 +12,7 @@
<radialGradient xlink:href="#g2" id="g4" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1, 0, 0, 0.481529, -718.417, 98.7046)" cx="323.75433" cy="209.73672" fx="323.75433" fy="209.73672" r="6.2794499"/>
<rect id="r1" fill="url(#g1)" width="100" height="100"/>
<rect id="r2" stroke="url(#g2)" width="100" height="100"/>
<rect id="r2" stroke="url('#g2')" width="100" height="100"/>
<rect id="r3" stroke="url(#g3)" width="100" height="100"/>
<rect id="r4" fill="url(#g4)" width="100" height="100"/>
</svg>
<rect id="r4" fill='url("#g4")' width="100" height="100"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before After
Before After