Adding and Inserting Children: AddChild adds given child at end of children list. The kid node is assumed to not be on another tree (see [MoveToParent]) and the existing name should be unique among children.
(kid Node)
| 306 | // The kid node is assumed to not be on another tree (see [MoveToParent]) |
| 307 | // and the existing name should be unique among children. |
| 308 | func (n *NodeBase) AddChild(kid Node) { |
| 309 | InitNode(kid) |
| 310 | n.Children = append(n.Children, kid) |
| 311 | SetParent(kid, n) // key to set new parent before deleting: indicates move instead of delete |
| 312 | } |
| 313 | |
| 314 | // NewChild creates a new child of the given type and adds it at the end |
| 315 | // of the list of children. The name defaults to the ID (kebab-case) name |