* Append childNode to parentNode, try to preserve some * whitespace / indentation for common scenarios.
(
parentNode: Node,
childNode: Node,
level: number,
indent: Function
)
| 423 | * whitespace / indentation for common scenarios. |
| 424 | */ |
| 425 | private appendChild( |
| 426 | parentNode: Node, |
| 427 | childNode: Node, |
| 428 | level: number, |
| 429 | indent: Function |
| 430 | ) { |
| 431 | const lastChild = parentNode.lastChild; |
| 432 | if (lastChild) { |
| 433 | parentNode.insertBefore(indent(parentNode, level), lastChild); |
| 434 | parentNode.insertBefore(childNode, lastChild); |
| 435 | } else { |
| 436 | parentNode.appendChild(indent(parentNode, level)); |
| 437 | parentNode.appendChild(childNode); |
| 438 | parentNode.appendChild(indent(parentNode, level - 1)); |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | private removeChildAndPrecedingText(parentNode: Node, childNode: Node) { |
| 443 | if (childNode.previousSibling?.nodeType === childNode.TEXT_NODE) { |
no test coverage detected