Skip to content

Commit 9aee9d7

Browse files
committed
Fix the following error:
http://lists.planetplanet.org/archives/devel/2007-August/001638.html Note: the fact that html5lib and the DOM produced differ on what the parent is for this child being removed may indicate a deeper software error. I've not investigaged further at this time. --HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40950
1 parent 79df4b1 commit 9aee9d7

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/html5lib/treebuilders/dom.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def insertBefore(self, node, refNode):
4141
node.parent = self
4242

4343
def removeChild(self, node):
44-
self.element.removeChild(node.element)
44+
if node.element.parentNode == self.element:
45+
self.element.removeChild(node.element)
4546
node.parent = None
4647

4748
def reparentChildren(self, newParent):

tests/test_lxp.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,19 @@ def test_prolog(self):
227227
<body>
228228
</body></html>""")
229229

230+
def test_tagsoup(self):
231+
self.assertXhtmlEquals(
232+
"""<html xmlns="http://www.w3.org/1999/xhtml">
233+
<head><title>TAGSOUP</title></head>
234+
<body>
235+
<u><blockquote><p></u>
236+
</body></html>""",
237+
"""<html xmlns="http://www.w3.org/1999/xhtml">
238+
<head><title>TAGSOUP</title></head>
239+
<body>
240+
<u/><blockquote><u/><p><u/>
241+
</p></blockquote></body></html>""")
242+
230243
def buildTestSuite():
231244
return unittest.defaultTestLoader.loadTestsFromName(__name__)
232245

0 commit comments

Comments
 (0)