From f2c5c6a76e0a3a7ae6d5fe603dab92cd32d20003 Mon Sep 17 00:00:00 2001 From: Charles Whittington Date: Sun, 1 Dec 2024 22:16:26 -0500 Subject: [PATCH 1/2] Reordered attribute priming in Node.__init__ --- src/travertino/node.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/travertino/node.py b/src/travertino/node.py index b0d50d5..1510bc7 100644 --- a/src/travertino/node.py +++ b/src/travertino/node.py @@ -1,5 +1,10 @@ class Node: def __init__(self, style, applicator=None, children=None): + # Parent needs to be primed before style is (potentially) applied with + # assignment of applicator. + self._parent = None + self._root = None + # Explicitly set the internal attribute first, since the setter for style will # access the applicator property. self._applicator = None @@ -7,8 +12,6 @@ def __init__(self, style, applicator=None, children=None): self.style = style self.applicator = applicator - self._parent = None - self._root = None if children is None: self._children = None else: From ceca42ec3c4b94e31022abdd8149f9f1176d4ffd Mon Sep 17 00:00:00 2001 From: Charles Whittington Date: Sun, 1 Dec 2024 22:23:53 -0500 Subject: [PATCH 2/2] Added changenote --- changes/239.misc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/239.misc.rst diff --git a/changes/239.misc.rst b/changes/239.misc.rst new file mode 100644 index 0000000..804c503 --- /dev/null +++ b/changes/239.misc.rst @@ -0,0 +1 @@ +The order in which attributes are primed in ``Node.__init__`` has been altered, so that ``.parent`` is available when a style is applied.