From 57dd5f5898e46fa14c1376dcdf9df1ae83c13072 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Mon, 3 Jun 2013 11:05:50 -0400 Subject: Save another Element creation. --- bs4/builder/_html5lib.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'bs4/builder/_html5lib.py') 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) -- cgit v1.2.3