Fix improper comparison of numeric default attribute values with text values resulting in wrongly removed attributes

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:25:05 +02:00
parent 3511c05298
commit 2e84d57efa

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)