summaryrefslogtreecommitdiff
path: root/bs4/builder/_html5lib.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonard.richardson@canonical.com>2013-06-03 11:05:50 -0400
committerLeonard Richardson <leonard.richardson@canonical.com>2013-06-03 11:05:50 -0400
commit57dd5f5898e46fa14c1376dcdf9df1ae83c13072 (patch)
tree9907eb8bf70c830abc7e5084e93a58835a259608 /bs4/builder/_html5lib.py
parent4cc522e01dae3fab54170060beef1389d528f6b6 (diff)
Save another Element creation.
Diffstat (limited to 'bs4/builder/_html5lib.py')
-rw-r--r--bs4/builder/_html5lib.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/bs4/builder/_html5lib.py b/bs4/builder/_html5lib.py
index 79f618a..6ed5055 100644
--- a/bs4/builder/_html5lib.py
+++ b/bs4/builder/_html5lib.py
@@ -129,6 +129,11 @@ class Element(html5lib.treebuilders._base.Node):
# instead of creating a TextElement object to contain the
# string.
string_child = child = node
+ elif isinstance(node, Tag):
+ # Some other piece of code decided to pass in a Tag
+ # instead of creating an Element object to contain the
+ # Tag.
+ child = node
elif node.element.__class__ == NavigableString:
string_child = child = node.element
else:
@@ -202,11 +207,7 @@ class Element(html5lib.treebuilders._base.Node):
while self.element.contents:
child = self.element.contents[0]
child.extract()
- if isinstance(child, Tag):
- newParent.appendChild(
- Element(child, self.soup, namespaces["html"]))
- else:
- newParent.appendChild(child)
+ newParent.appendChild(child)
def cloneNode(self):
tag = self.soup.new_tag(self.element.name, self.namespace)