summaryrefslogtreecommitdiff
path: root/bs4/builder/_html5lib.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2013-10-18 13:03:06 -0400
committerLeonard Richardson <leonardr@segfault.org>2013-10-18 13:03:06 -0400
commit991921744807a02f36feaeb9ece9dd519915a886 (patch)
treeb4ace80a186e011267e3a2f9e4c98dc181b5a7ca /bs4/builder/_html5lib.py
parent81b1a39ab4a233c4fb5fe8aa77e81cd67c44dc78 (diff)
Fixed yet another problem that caused the html5lib tree builder to
create a disconnected parse tree. [bug=1237763]
Diffstat (limited to 'bs4/builder/_html5lib.py')
-rw-r--r--bs4/builder/_html5lib.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/bs4/builder/_html5lib.py b/bs4/builder/_html5lib.py
index 7de36ae..6446c2e 100644
--- a/bs4/builder/_html5lib.py
+++ b/bs4/builder/_html5lib.py
@@ -161,6 +161,12 @@ class Element(html5lib.treebuilders._base.Node):
# immediately after the parent, if it has no children.)
if self.element.contents:
most_recent_element = self.element._last_descendant(False)
+ elif self.element.next_element is not None:
+ # Something from further ahead in the parse tree is
+ # being inserted into this earlier element. This is
+ # very annoying because it means an expensive search
+ # for the last element in the tree.
+ most_recent_element = self.soup._last_descendant()
else:
most_recent_element = self.element