(Partial?) fix for bug 594930: In a <switch>, require one level of <g> if there was a <g> in the file already. Otherwise, only the first subelement of the <g> is chosen and rendered.

This commit is contained in:
Cynthia Gauthier 2010-06-16 02:29:01 -04:00
parent 26d90a7529
commit bb1a38a7ad

View file

@ -749,15 +749,18 @@ def removeNestedGroups(node):
num = 0 num = 0
groupsToRemove = [] groupsToRemove = []
for child in node.childNodes: # Only consider <g> elements for promotion if this element isn't a <switch>.
if child.nodeName == 'g' and child.namespaceURI == NS['SVG'] and len(child.attributes) == 0: # (partial fix for bug 594930, required by the SVG spec however)
# only collapse group if it does not have a title or desc as a direct descendant if not (node.nodeType == 1 and node.nodeName == 'switch'):
for grandchild in child.childNodes: for child in node.childNodes:
if grandchild.nodeType == 1 and grandchild.namespaceURI == NS['SVG'] and \ if child.nodeName == 'g' and child.namespaceURI == NS['SVG'] and len(child.attributes) == 0:
grandchild.nodeName in ['title','desc']: # only collapse group if it does not have a title or desc as a direct descendant,
break for grandchild in child.childNodes:
else: if grandchild.nodeType == 1 and grandchild.namespaceURI == NS['SVG'] and \
groupsToRemove.append(child) grandchild.nodeName in ['title','desc']:
break
else:
groupsToRemove.append(child)
for g in groupsToRemove: for g in groupsToRemove:
while g.childNodes.length > 0: while g.childNodes.length > 0: