Fixed !important not applying to border

This commit is contained in:
Dave Pearson
2023-05-01 14:17:29 +01:00
parent 8fac2c7d2a
commit 5a355da78b
2 changed files with 15 additions and 0 deletions

View File

@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## Unreleased
### Fixed
- Fixed `!important` not applying to `border` https://github.com/Textualize/textual/issues/2420
## [0.22.3] - 2023-04-29

View File

@@ -486,6 +486,16 @@ class StylesBuilder:
rules = self.styles._rules
rules["border_top"] = rules["border_right"] = border
rules["border_bottom"] = rules["border_left"] = border
# If border is marked as important...
if "border" in self.styles.important:
# ...border alone at this depth isn't really a thing, only
# border edges (that's to say, border gets expanded out to all 4
# edges). So we remove "border" as important and mark all the
# edges as important.
self.styles.important.remove("border")
self.styles.important.update(
f"border_{edge}" for edge in ("top", "left", "bottom", "right")
)
def process_border_top(self, name: str, tokens: list[Token]) -> None:
self._process_border_edge("top", name, tokens)