summaryrefslogtreecommitdiff
path: root/bs4/tests
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2023-04-17 09:34:58 -0400
committerLeonard Richardson <leonardr@segfault.org>2023-04-17 09:34:58 -0400
commit31eb728f84cd795f432838ba58d2bbf9502520db (patch)
tree9937db86e970e80b4ebf6a13a3abd3db5f7da007 /bs4/tests
parentc4a7d44e76b1784185946682d4111759f48ac0bd (diff)
Fixed a regression such that if you set .hidden on a tag, the tag
becomes invisible but its contents are still visible. User manipulation of .hidden is not a documented or supported feature, so don't do this, but it's not too difficult to keep the old behavior working.
Diffstat (limited to 'bs4/tests')
-rw-r--r--bs4/tests/test_tag.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/bs4/tests/test_tag.py b/bs4/tests/test_tag.py
index 88cc202..c48f334 100644
--- a/bs4/tests/test_tag.py
+++ b/bs4/tests/test_tag.py
@@ -219,3 +219,16 @@ class TestMultiValuedAttributes(SoupTest):
)
assert soup.a['class'] == 'foo'
assert soup.a['id'] == ['bar']
+
+ def test_hidden_tag_is_invisible(self):
+ # Setting .hidden on a tag makes it invisible in output, but
+ # leaves its contents visible.
+ #
+ # This is not a documented or supported feature of Beautiful
+ # Soup (e.g. NavigableString doesn't support .hidden even
+ # though it could), but some people use it and it's not
+ # hurting anything to verify that it keeps working.
+ #
+ soup = self.soup('<div id="1"><span id="2">a string</span></div>')
+ soup.span.hidden = True
+ assert '<div id="1">a string</div>' == str(soup.div)