diff --git a/.pytest.expect b/.pytest.expect index 8bfcf4b7..f03e18f8 100644 --- a/.pytest.expect +++ b/.pytest.expect @@ -208,51 +208,6 @@ u'html5lib/tests/testdata/tree-construction/isindex.dat::3::cElementTree::parser u'html5lib/tests/testdata/tree-construction/isindex.dat::3::cElementTree::parser::void-namespace': FAIL u'html5lib/tests/testdata/tree-construction/isindex.dat::3::lxml::parser::namespaced': FAIL u'html5lib/tests/testdata/tree-construction/isindex.dat::3::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::0::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::0::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::0::DOM::treewalker': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::0::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::0::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::0::ElementTree::treewalker': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::0::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::0::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::0::cElementTree::treewalker': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::0::genshi::treewalker': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::0::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::0::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::0::lxml::treewalker': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::1::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::1::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::1::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::1::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::1::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::1::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::1::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::1::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::2::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::2::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::2::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::2::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::2::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::2::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::2::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::2::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::3::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::3::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::3::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::3::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::3::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::3::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::3::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::3::lxml::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::4::DOM::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::4::DOM::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::4::ElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::4::ElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::4::cElementTree::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::4::cElementTree::parser::void-namespace': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::4::lxml::parser::namespaced': FAIL -u'html5lib/tests/testdata/tree-construction/math.dat::4::lxml::parser::void-namespace': FAIL u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::3::DOM::parser::namespaced': FAIL u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::3::DOM::parser::void-namespace': FAIL u'html5lib/tests/testdata/tree-construction/menuitem-element.dat::3::ElementTree::parser::namespaced': FAIL diff --git a/html5lib/treebuilders/_base.py b/html5lib/treebuilders/_base.py index 900a724c..a4b2792a 100644 --- a/html5lib/treebuilders/_base.py +++ b/html5lib/treebuilders/_base.py @@ -167,12 +167,17 @@ def elementInScope(self, target, variant=None): # If we pass a node in we match that. if we pass a string # match any node with that name exactNode = hasattr(target, "nameTuple") + if not exactNode: + if isinstance(target, text_type): + target = (namespaces["html"], target) + assert isinstance(target, tuple) listElements, invert = listElementsMap[variant] for node in reversed(self.openElements): - if (node.name == target and not exactNode or - node == target and exactNode): + if exactNode and node == target: + return True + elif not exactNode and node.nameTuple == target: return True elif (invert ^ (node.nameTuple in listElements)): return False