summaryrefslogtreecommitdiff
path: root/bs4/builder
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
commita4dc03578d20923ced0205e1aaf09c89f5bfa8f2 (patch)
treec8f644c48209360a198818026ab8ef6d05b1c2d1 /bs4/builder
parenta31f64208912e50d5fc6e5dd1d3f7fd3fd6be281 (diff)
downloadbeautifulsoup4-a4dc03578d20923ced0205e1aaf09c89f5bfa8f2.tar.gz
Fixed yet another problem that caused the html5lib tree builder to
create a disconnected parse tree. [bug=1237763]
Diffstat (limited to 'bs4/builder')
-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