title: Can I convert an HTML comment to actual HTML using JavaScript?
body: <p>If I insert a comment node into a document fragment, can I convert it to HTML later? Example:</p>
  
  <pre><code>var fragment = document.createDocumentFragment();
  var comment = document.createComment('&lt;div&gt;Testing&lt;/div&gt;');
  
  fragment.appendChild(comment);
  
  // Convert comment into actual HTML?
  </code></pre>
  
  <p>What this would look like inside of a fragment:</p>
  
  <pre><code>&lt;!--&lt;div&gt;Testing&lt;/div&gt;--&gt;
  </code></pre>
  
  <p>And how it should be when done (actual DOM):</p>
  
  <pre><code>&lt;div&gt;Testing&lt;/div&gt;
  </code></pre>
  
  <hr>
  
  <p><strong><em>Background:</em></strong></p>
  
  <p>There are many limitations for inserting HTML into a fragment. Fragments don't support <code>innerHTML</code> or <code>insertAdjacentHTML</code> etc. There are other methods for getting HTML into fragments, but they drop certain elements and leave only the inner text. For example, creating a fragment with the <code>createRange</code> API drops those types of nodes and I will be left with a fragment with just the text node "Data"</p>
  
  <pre><code>var fragment = document.createRange().createContextualFragment('&lt;td&gt;Data&lt;/td&gt;');
  </code></pre>
  
  <p>The hope is that if I can convert a comment into actual DOM, that it will work as expected.</p>