Refine CSS classes remove method to only warn if passed a non-existent path (previously would throw an exception). (#2450)

* Refine CSS classes remove method to only warn if passed a non-existent path (previously would throw an exception).

* Refine console import.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Nicholas Tollervey
2026-02-05 12:31:53 +00:00
committed by GitHub
parent b052ad6fb7
commit d6f401a0c4
3 changed files with 33 additions and 10 deletions

View File

@@ -337,6 +337,10 @@ class TestElement:
assert div.classes == {"class1", "class2", "class3"}
div.classes.remove("class2 class3")
assert div.classes == {"class1"}
# Remove the final class
div.classes.remove("class1")
# Removing a non-existent class should not raise an error.
div.classes.remove("non-existent-class")
async def test_when_decorator(self):
called = False