Skip to content

Commit

Permalink
definsive repr
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Sep 19, 2023
1 parent c2a1d82 commit 32a0091
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/textual/dom.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,12 @@ def _post_register(self, app: App) -> None:
"""

def __rich_repr__(self) -> rich.repr.Result:
yield "name", self._name, None
yield "id", self._id, None
if self._classes:
# Being a bit defensive here to guard against errors when calling repr before initialization
if hasattr(self, "_name"):
yield "name", self._name, None
if hasattr(self, "_id"):
yield "id", self._id, None
if hasattr(self, "_classes") and self._classes:
yield "classes", " ".join(self._classes)

def _get_default_css(self) -> list[tuple[str, str, int]]:
Expand Down

0 comments on commit 32a0091

Please sign in to comment.