scour: Fix another variant of the crash from #260 (#264)

Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
Niels Thykier 2020-11-22 14:00:43 +00:00 committed by GitHub
parent 92e64f0d7f
commit b8a071f995
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 30 deletions

View file

@ -1200,11 +1200,11 @@ def mergeSiblingGroupsWithCommonAttributes(elem):
for node in nodes:
if node.nodeType == Node.ELEMENT_NODE and node.nodeName == 'g' and node.namespaceURI == NS['SVG']:
# Merge
primaryGroup.childNodes.extend(node.childNodes)
node.childNodes = []
for child in node.childNodes[:]:
primaryGroup.appendChild(child)
elem.removeChild(node).unlink()
else:
primaryGroup.childNodes.append(node)
elem.childNodes.remove(node)
primaryGroup.appendChild(node)
# each child gets the same treatment, recursively
for childNode in elem.childNodes: