index.js
function recurse(node) {
    // first navigate to the first sibling
    if (node.previousSibling) recurse(node.previousSibling);
    // then add the string representation of the nodes ('backward' recursion)
    switch (node.nodeType) {
      case 8: // comment
        html += "<!--" + node.nodeValue + "-->";
        break;
        // case 10: // doctype: jsDom does not know doctype as previousSibling.
    }
  }
function recurse(node) {
    // first navigate to the first sibling
    if (node.previousSibling) recurse(node.previousSibling);
    // then add the string representation of the nodes ('backward' recursion)
    switch (node.nodeType) {
      case 8: // comment
        html += "<!--" + node.nodeValue + "-->";
        break;
        // case 10: // doctype: jsDom does not know doctype as previousSibling.
    }
  }
add previous siblings