* Removes all children of the current node. * * @method empty * @return {tinymce.html.Node} The current node that got cleared.
()
| 466 | * @return {tinymce.html.Node} The current node that got cleared. |
| 467 | */ |
| 468 | public empty(): AstNode { |
| 469 | const self = this; |
| 470 | |
| 471 | // Remove all children |
| 472 | if (self.firstChild) { |
| 473 | const nodes = []; |
| 474 | |
| 475 | // Collect the children |
| 476 | for (let node: AstNode | null | undefined = self.firstChild; node; node = walk(node, self)) { |
| 477 | nodes.push(node); |
| 478 | } |
| 479 | |
| 480 | // Remove the children |
| 481 | let i = nodes.length; |
| 482 | while (i--) { |
| 483 | const node = nodes[i]; |
| 484 | node.parent = node.firstChild = node.lastChild = node.next = node.prev = null; |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | self.firstChild = self.lastChild = null; |
| 489 | |
| 490 | return self; |
| 491 | } |
| 492 | |
| 493 | /** |
| 494 | * Returns true/false if the node is to be considered empty or not. |
no test coverage detected