function getChildIndex(node: Element) { return Array.prototype.indexOf.call(node.parentElement!.childNodes, node); } function isWhitespaceNode(node: Node) { return node.nodeType === 3 && !/\S/.test(node.nodeValue || ""); } /** * Step 1, Turns: * *