* Appends a new node as a child of the current node. * * @method append * @param {tinymce.html.Node} node Node to append as a child of the current one. * @return {tinymce.html.Node} The node that got appended. * @example * node.append(someNode);
(node: AstNode)
| 356 | * node.append(someNode); |
| 357 | */ |
| 358 | public append(node: AstNode): AstNode { |
| 359 | const self = this; |
| 360 | |
| 361 | if (node.parent) { |
| 362 | node.remove(); |
| 363 | } |
| 364 | |
| 365 | const last = self.lastChild; |
| 366 | if (last) { |
| 367 | last.next = node; |
| 368 | node.prev = last; |
| 369 | self.lastChild = node; |
| 370 | } else { |
| 371 | self.lastChild = self.firstChild = node; |
| 372 | } |
| 373 | |
| 374 | node.parent = self; |
| 375 | |
| 376 | return node; |
| 377 | } |
| 378 | |
| 379 | /** |
| 380 | * Inserts a node at a specific position as a child of this node. |
no test coverage detected