mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add Styles.reset method revert internal attributes to None
This commit is contained in:
@@ -235,6 +235,10 @@ class Styles:
|
||||
else:
|
||||
return None
|
||||
|
||||
def reset(self) -> None:
|
||||
for rule_name in INTERNAL_RULE_NAMES:
|
||||
setattr(self, rule_name, None)
|
||||
|
||||
def extract_rules(
|
||||
self, specificity: Specificity3
|
||||
) -> list[tuple[str, Specificity4, Any]]:
|
||||
|
||||
@@ -114,7 +114,7 @@ class Stylesheet:
|
||||
|
||||
_check_rule = self._check_rule
|
||||
|
||||
node.reset_styles()
|
||||
node.styles.reset()
|
||||
|
||||
# Get the default node CSS rules
|
||||
for key, default_specificity, value in node._default_rules:
|
||||
|
||||
11
tests/test_styles.py
Normal file
11
tests/test_styles.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from rich.style import Style
|
||||
|
||||
from textual.css.styles import Styles
|
||||
|
||||
|
||||
def test_styles_reset():
|
||||
styles = Styles()
|
||||
styles.text_style = "not bold"
|
||||
assert styles.text_style == Style(bold=False)
|
||||
styles.reset()
|
||||
assert styles.text_style is Style.null()
|
||||
Reference in New Issue
Block a user