diff --git a/mwparserfromhell/nodes/tag.py b/mwparserfromhell/nodes/tag.py index 08d5204..d63af02 100644 --- a/mwparserfromhell/nodes/tag.py +++ b/mwparserfromhell/nodes/tag.py @@ -89,7 +89,7 @@ class Tag(Node): yield self.closing_tag, child def __strip__(self, normalize, collapse): - if is_visible(self.tag): + if self.contents and is_visible(self.tag): return self.contents.strip_code(normalize, collapse) return None diff --git a/tests/test_tag.py b/tests/test_tag.py index 6755270..a7a4b4a 100644 --- a/tests/test_tag.py +++ b/tests/test_tag.py @@ -102,10 +102,12 @@ class TestTag(TreeEqualityTestCase): """test Tag.__strip__()""" node1 = Tag(wraptext("i"), wraptext("foobar")) node2 = Tag(wraptext("math"), wraptext("foobar")) + node3 = Tag(wraptext("br"), self_closing=True) for a in (True, False): for b in (True, False): self.assertEqual("foobar", node1.__strip__(a, b)) self.assertEqual(None, node2.__strip__(a, b)) + self.assertEqual(None, node3.__strip__(a, b)) def test_showtree(self): """test Tag.__showtree__()"""