title: Uncaught Error: NOT_FOUND_ERR: DOM Exception 8 on insertBefore
body: <pre><code>function create(htmlStr) {
      var frag = document.createDocumentFragment(),
          temp = document.createElement('div');
      temp.innerHTML = htmlStr;
      while (temp.firstChild) {
          frag.appendChild(temp.firstChild);
      }
      return frag;
  }
  
  function add(identifier, html){
      var frag = create(html);
      document.body.insertBefore(frag, document.getElementById(identifier));
  }
  </code></pre>
  
  <p><code>identifier</code> is the string id of a tag that I've verified in developer tools exists, <code>html</code> is just the fragment I want to prepend to the element denoted by said <code>identifier</code>. <code>frag</code> is a bonefide html fragment, and the call to <code>getElementById</code> returns a bonefide element ie neither are strings. Why am I getting the above error on <code>insertBefore</code>?</p>