| 171 | } |
| 172 | |
| 173 | function remove(child: TestNode, logOp = true): void { |
| 174 | const parent = child.parentNode |
| 175 | if (parent) { |
| 176 | if (logOp) { |
| 177 | logNodeOp({ |
| 178 | type: NodeOpTypes.REMOVE, |
| 179 | targetNode: child, |
| 180 | parentNode: parent, |
| 181 | }) |
| 182 | } |
| 183 | const i = parent.children.indexOf(child) |
| 184 | if (i > -1) { |
| 185 | parent.children.splice(i, 1) |
| 186 | } else { |
| 187 | console.error('target: ', child) |
| 188 | console.error('parent: ', parent) |
| 189 | throw Error('target is not a childNode of parent') |
| 190 | } |
| 191 | child.parentNode = null |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | function setElementText(el: TestElement, text: string): void { |
| 196 | logNodeOp({ |