Properly set the parentNode on created <g> elements and their children for --create-groups, to avoid trouble later on.

This commit is contained in:
Louis Simard 2010-08-11 23:25:06 -04:00
parent beccc7c577
commit b7277e0877

View file

@ -956,10 +956,13 @@ def createGroupsForCommonAttributes(elem):
# Move the run of elements to the group. # Move the run of elements to the group.
# a) ADD the nodes to the new group. # a) ADD the nodes to the new group.
group.childNodes[:] = elem.childNodes[runStart:runEnd + 1] group.childNodes[:] = elem.childNodes[runStart:runEnd + 1]
for child in group.childNodes:
child.parentNode = group
# b) REMOVE the nodes from the element. # b) REMOVE the nodes from the element.
elem.childNodes[runStart:runEnd + 1] = [] elem.childNodes[runStart:runEnd + 1] = []
# Include the group in elem's children. # Include the group in elem's children.
elem.childNodes.insert(runStart, group) elem.childNodes.insert(runStart, group)
group.parentNode = elem
num += 1 num += 1
curChild = runStart - 1 curChild = runStart - 1
numElemsRemoved -= 1 numElemsRemoved -= 1