* Replaces the current node with the specified one. * * @method replace * @param {tinymce.html.Node} node Node to replace the current node with. * @return {tinymce.html.Node} The old node that got replaced. * @example * someNode.replace(someNewNode);
(node: AstNode)
| 149 | * someNode.replace(someNewNode); |
| 150 | */ |
| 151 | public replace(node: AstNode): AstNode { |
| 152 | const self = this; |
| 153 | |
| 154 | if (node.parent) { |
| 155 | node.remove(); |
| 156 | } |
| 157 | |
| 158 | self.insert(node, self); |
| 159 | self.remove(); |
| 160 | |
| 161 | return self; |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * Gets/sets or removes an attribute by name. |
no test coverage detected