Fix improper comparison of numeric default attribute values with textvalues resulting in wrongly removed attributes (#101)

For example for `orient="auto"` SVGLength() returns (value=0, units=Unit.INVALID); since the default value for `orient` is zero it was removed as there was check for a valid unit.
This commit is contained in:
Eduard Braun 2016-08-29 06:37:28 +02:00 committed by GitHub
parent 3511c05298
commit 842123a393
3 changed files with 23 additions and 3 deletions

View file

@ -1750,7 +1750,7 @@ def removeDefaultAttributeValue(node, attribute):
return 1
else:
nodeValue = SVGLength(node.getAttribute(attribute.name))
if (attribute.value is None) or (nodeValue.value == attribute.value):
if (attribute.value is None) or ((nodeValue.value == attribute.value) and not (nodeValue.units == Unit.INVALID)):
if (attribute.units is None) or (nodeValue.units == attribute.units) or (isinstance(attribute.units, list) and nodeValue.units in attribute.units):
if (attribute.conditions is None) or attribute.conditions(node):
node.removeAttribute(attribute.name)