duck.html.components.core.childrenΒΆ
Module containing a specialized children list for managing child components insertion and deletion.
Module ContentsΒΆ
ClassesΒΆ
A specialized list to manage child components of an InnerComponent. |
APIΒΆ
- class duck.html.components.core.children.ChildrenList(parent: duck.html.components.Component, initlist=None, skip_initlist_events: bool = False)[source]ΒΆ
Bases:
duck.utils.eventlist.EventListA specialized list to manage child components of an InnerComponent.
This class ensures that child components maintain correct parent-child relationships by updating references whenever a child is added or removed.
Inherits from: EventList: A custom list that provides hooks for item insertion and deletion.
Initialization
Initializes the ChildrenList with a reference to its parent component.
- Parameters:
parent β The parent component to which children belong.
initlist β The initialization list to start with.
skip_initlist_events β Whether to skip calling event handler for each item in initlist.
- Raises:
ComponentError β If the parent is not a valid InnerComponent.
- _update_root_iterative(node: Component, new_root: Component)[source]ΒΆ
Iteratively update roots of a subtree. Uses a stack (DFS) to avoid recursion overhead.
- on_delete_child(child: duck.html.components.Component)[source]ΒΆ
Handler called when a child is removed or replaced from the list.
Clears the parent and root references of the child component.
- Parameters:
child β The child component being removed.
- Raises:
ComponentError β If the child is not a valid component or not in the list.