You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: w3/python/core/fundamental_interface/Node.py
+41Lines changed: 41 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -301,6 +301,47 @@ def insert_before(self,
301
301
new_child._set_parent_node(self)
302
302
returnnew_child
303
303
304
+
defreplace_child(self,
305
+
new_child: _AnyNode,
306
+
old_child: _AnyNode) ->_AnyNode:
307
+
"""Replaces the child node `old_child` with `new_child` in the list of children, and returns the `old_child` node.
308
+
309
+
If the `new_child` is already in the tree, it is first removed.
310
+
311
+
Args:
312
+
new_child: The new node to put in the child list.
313
+
old_child: The node being replaced in the list.
314
+
315
+
Returns:
316
+
The node replaced.
317
+
318
+
Raisees:
319
+
DOMException:
320
+
- `HIERARCHY_REQUEST_ERR`: Raised if this node is of a type that does not allow children of the type of the `new_child` node, or it the node to put in is one of this node's ancestors.
321
+
- `WRONG_DOCUMENT_ERR`: Raised if `new_child` was created from a different document than the one that created this node.
322
+
- `NO_MODIFICATION_ALLOWED_ERR`: Raised if this node is readonly.
323
+
- `NOT_FOUND_ERR`: Raised if `old_child` is not a child of this node.
324
+
"""
325
+
# `HIERARCHY_REQUEST_ERR` should be checked on subclasses by overriding.
0 commit comments