Check xlink:href for gradientUnits="userSpaceOnUse"

When considering to prune attributes set to a default values, we
checked the `gradientUnits` attribute first to determine if that was
valid. Unfortunately, we omitted to check whether the `gradientUnits`
attribute was inherited via `xlink:ref`.  This commit corrects that
bug.

Closes: #225
Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
Niels Thykier 2021-02-27 22:14:50 +00:00
parent fbf0c06e84
commit e0e3f81632
No known key found for this signature in database
GPG key ID: A65B78DBE67C7AAC
3 changed files with 71 additions and 12 deletions

View file

@ -1517,8 +1517,21 @@ class RemoveRedundantSvgNamespacePrefix(unittest.TestCase):
class RemoveDefaultGradX1Value(unittest.TestCase):
def runTest(self):
g = scourXmlFile('unittests/gradient-default-attrs.svg').getElementById('grad1')
self.assertEqual(g.getAttribute('x1'), '',
doc = scourXmlFile('unittests/gradient-default-attrs.svg')
g1 = doc.getElementById('grad1')
g1b = doc.getElementById('grad1b')
g1c = doc.getElementById('grad1c')
g1d = doc.getElementById('grad1d')
g1e = doc.getElementById('grad1e')
self.assertEqual(g1.getAttribute('x1'), '',
'x1="0" not removed')
self.assertEqual(g1b.getAttribute('x1'), '',
'x1="0" not removed')
self.assertEqual(g1c.getAttribute('x1'), '',
'x1="0" removed (but should not be due to gradientUnits)')
self.assertEqual(g1d.getAttribute('x1'), '',
'x1="0" removed (but should not be due to href)')
self.assertEqual(g1e.getAttribute('x1'), '',
'x1="0" not removed')