From e82a52cacd936b66d9f6290136278af00ea1428c Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Thu, 26 Apr 2012 10:08:45 -0400 Subject: The test suite now passes when lxml is not installed, whether or not html5lib is installed. [bug=987004] --- bs4/builder/_html5lib.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'bs4/builder/_html5lib.py') diff --git a/bs4/builder/_html5lib.py b/bs4/builder/_html5lib.py index 2d6fe31..6001e38 100644 --- a/bs4/builder/_html5lib.py +++ b/bs4/builder/_html5lib.py @@ -139,11 +139,20 @@ class Element(html5lib.treebuilders._base.Node): return AttrList(self.element) def setAttributes(self, attributes): - if attributes is not None and attributes != {}: + if attributes is not None and len(attributes) > 0: + + converted_attributes = [] for name, value in list(attributes.items()): if isinstance(name, tuple): - name = NamespacedAttribute(*name) - self.element[name] = value + new_name = NamespacedAttribute(*name) + del attributes[name] + attributes[new_name] = value + + self.soup.builder._replace_cdata_list_attribute_values( + self.name, attributes) + for name, value in attributes.items(): + self.element[name] = value + # The attributes may contain variables that need substitution. # Call set_up_substitutions manually. # -- cgit v1.2.3