Walk
Functions for walking the DOM.
Note
For most purposes you would be better off using query, which uses these functions internally.
walk_breadth_first
function
¶
Walk the tree breadth first (children first).
Note
Avoid changing the DOM (mounting, removing etc.) while iterating with this function. Consider walk_children which doesn't have this limitation.
Parameters
Parameter | Default | Description |
---|---|---|
root
DOMNode
|
required | The root note (starting point). |
filter_type
type[WalkType] | None
|
None
|
Optional DOMNode subclass to filter by, or |
with_root
bool
|
True
|
Include the root in the walk. |
Returns
Type | Description |
---|---|
Iterable[DOMNode] | Iterable[WalkType]
|
An iterable of DOMNodes, or the type specified in |
walk_depth_first
function
¶
Walk the tree depth first (parents first).
Note
Avoid changing the DOM (mounting, removing etc.) while iterating with this function. Consider walk_children which doesn't have this limitation.
Parameters
Parameter | Default | Description |
---|---|---|
root
DOMNode
|
required | The root note (starting point). |
filter_type
type[WalkType] | None
|
None
|
Optional DOMNode subclass to filter by, or |
with_root
bool
|
True
|
Include the root in the walk. |
Returns
Type | Description |
---|---|
Iterable[DOMNode] | Iterable[WalkType]
|
An iterable of DOMNodes, or the type specified in |