From 2e84d57efa4325b31945ed1b9b641f6fe6f6dd14 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Mon, 29 Aug 2016 06:25:05 +0200 Subject: [PATCH] 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. --- scour/scour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scour/scour.py b/scour/scour.py index 2fc4921..53bb36e 100644 --- a/scour/scour.py +++ b/scour/scour.py @@ -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)