Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 17x 17x 8x 8x 8x 8x 22x 1x 22x 8x 14x 14x | import { beginMarker, endMarker } from "../createTemplate";
export default function removeLeftSiblings(markerNode: Node) {
const {
parentNode
} = markerNode;
let sibling = markerNode.previousSibling;
// Keep the count of end markers to know how many beign markers to remove, which should correspond to the number of end markers found
let endMarkersCount: number = 1; // The marker node should be the first end marker found
while (sibling !== null) {
if ((sibling as Comment).data === endMarker) {
++endMarkersCount;
}
if ((sibling as Comment).data === beginMarker &&
--endMarkersCount === 0) { // Decrements the end marker
break; // Got the desired begin marker ... done
}
parentNode.removeChild(sibling);
sibling = markerNode.previousSibling;
}
} |