title: Removing an element through the parentNode.removeChild throws a DOM Exception 8
body: <p>I have code which is roughly as follows (I removed some parts, as they are irrelevant):</p>
  
  <pre><code>Library.focus = function(event) {
      var element, paragraph;
  
      element = event.srcElement;
  
      paragraph = document.createElement("p");
      paragraph.innerText = element.innerText;
  
      element.parentNode.insertBefore(paragraph, element);        // Line #1
      element.parentNode.removeChild(element);                    // Line #2
  };
  </code></pre>
  
  <p>The issue I have, is that the last call which I've numbered as line #2 throws this:</p>
  
  <pre><code>Uncaught Error: NOT_FOUND_ERR: DOM Exception 8
  </code></pre>
  
  <p>Note that the previous line #1 works fine, and inserts the paragraph node before it.
  Element is an existing element, and both element.parentNode and element.parentNode.removeChild exist as well.</p>
  
  <p>I find this illogical, as element is by definition a child of its parentNode.
  Maybe StackOverflow will be able to help me out, here?</p>