#1433694: minidom's .normalize() failed to set .nextSibling for last element.

Fix by Malte Helmert
This commit is contained in:
Andrew M. Kuchling 2008-02-23 17:21:44 +00:00
parent be0adfcfa8
commit 05a19a507d
4 changed files with 15 additions and 0 deletions

View File

@ -806,6 +806,14 @@ def testNormalize():
"testNormalize -- single empty node removed") "testNormalize -- single empty node removed")
doc.unlink() doc.unlink()
def testBug1433694():
doc = parseString("<o><i/>t</o>")
node = doc.documentElement
node.childNodes[1].nodeValue = ""
node.normalize()
confirm(node.childNodes[-1].nextSibling == None,
"Final child's .nextSibling should be None")
def testSiblings(): def testSiblings():
doc = parseString("<doc><?pi?>text?<elm/></doc>") doc = parseString("<doc><?pi?>text?<elm/></doc>")
root = doc.documentElement root = doc.documentElement

View File

@ -203,6 +203,8 @@ class Node(xml.dom.Node):
L.append(child) L.append(child)
if child.nodeType == Node.ELEMENT_NODE: if child.nodeType == Node.ELEMENT_NODE:
child.normalize() child.normalize()
if L:
L[-1].nextSibling = None
self.childNodes[:] = L self.childNodes[:] = L
def cloneNode(self, deep): def cloneNode(self, deep):

View File

@ -266,6 +266,7 @@ Shane Hathaway
Rycharde Hawkes Rycharde Hawkes
Jochen Hayek Jochen Hayek
Thomas Heller Thomas Heller
Malte Helmert
Lance Finn Helsten Lance Finn Helsten
Jonathan Hendry Jonathan Hendry
James Henstridge James Henstridge

View File

@ -15,6 +15,10 @@ Core and builtins
Library Library
------- -------
- Bug #1433694: minidom's .normalize() failed to set .nextSibling for
last child element.
Extension Modules Extension Modules
----------------- -----------------