Properly set the parentNode on created <g> elements and their children for --create-groups, to avoid trouble later on.
This commit is contained in:
parent
beccc7c577
commit
b7277e0877
1 changed files with 3 additions and 0 deletions
3
scour.py
3
scour.py
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue