title: JSDOM: dom.window.document.innerHTML is undefined
body: <p>I am creating a node.js script to parse the content from a website. Before I work with the returned HTML I want to remove a few elements and properties. However, when trying to retrieve the HTML from jsdom I am only returned <code>undefined</code>. This appears to happen before I make my modifications to the HTML. How can I use jsdom to modify the HTML and return it?</p>
  
  <pre><code>const jsdom = require('jsdom');
  ...
  var htmlString = `&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;&lt;html lang=en&gt;&lt;head&gt;...`
  paresHTML(htmlString);
  
  function parseHTML(htmlString) {
      const dom = new jsdom.JSDOM(htmlString);
  
      console.log(dom.window.document.innerHTML); // This returns undefined
  
      dom.window.document.querySelectorAll('script').forEach(element =&gt; element.remove());
      dom.window.document.querySelectorAll('head').forEach(element =&gt; element.remove());
      dom.window.document.querySelectorAll('link').forEach(element =&gt; element.remove());
      dom.window.document.querySelectorAll('style').forEach(element =&gt; element.remove());
      dom.window.document.querySelectorAll('iframe').forEach(element =&gt; element.remove());
  
      dom.window.document.querySelectorAll('noscript').forEach((element) =&gt; {
          var replacement = dom.window.document.createElement('div');
          replacement.setAttribute('class', 'noscript');
          replacement.innerHTML = element.innerHTML;
          element.parentNode.replaceChild(replacement, element);
      });
  
      dom.window.document.querySelectorAll('img[src]').forEach((element) =&gt; {
          const src = element.getAttribute('src');
          element.setAttribute('data-src', src);
          element.removeAttribute('src');
      });
  
      dom.window.document.querySelectorAll('[style]').forEach((element) =&gt; {
          element.removeAttribute('style');
      });
  
      return dom.window.document.innerHTML; // This also returns undefined
  }
  </code></pre>