Closed ioxu closed 11 months ago
change_container()
is messy. This should help generalise.
.. cannot replace the root Container
of course.
added .replace_by()
It's mostly to make utilising code shorter.
use
if container.parent is None:
container.set_child( new_container, 0 )
else:
container = container.replace_by( new_container )
which is all very smelly.
Presently there is
parent_container.replace_child()
.Should add
Contaner.replace()
to hide parent logic inside Container.usage here, but should work regardless if a
Container
has a parent (is a root) or not: https://github.com/ioxu/boxer/blob/9d16528a92268d7a1a3d71ae1c3dd886549bbb14/boxer/containers.py#L710.replace_child()
implemented here: https://github.com/ioxu/boxer/blob/9d16528a92268d7a1a3d71ae1c3dd886549bbb14/boxer/containers.py#L184