From b7277e0877f61f15a87c9786fb3915e45e746eb9 Mon Sep 17 00:00:00 2001 From: Louis Simard Date: Wed, 11 Aug 2010 23:25:06 -0400 Subject: [PATCH] Properly set the parentNode on created elements and their children for --create-groups, to avoid trouble later on. --- scour.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scour.py b/scour.py index 0436872..a654597 100755 --- a/scour.py +++ b/scour.py @@ -956,10 +956,13 @@ def createGroupsForCommonAttributes(elem): # Move the run of elements to the group. # a) ADD the nodes to the new group. group.childNodes[:] = elem.childNodes[runStart:runEnd + 1] + for child in group.childNodes: + child.parentNode = group # b) REMOVE the nodes from the element. elem.childNodes[runStart:runEnd + 1] = [] # Include the group in elem's children. elem.childNodes.insert(runStart, group) + group.parentNode = elem num += 1 curChild = runStart - 1 numElemsRemoved -= 1