title: D3 TypeError: link.exit is not a function link.exit().remove(); What am I doing wrong?
body: <p>I'm making a D3 tree layout. I've looked all over and it seems like this error shows up when you don't have data tied to the DOM and you try to remove it. I've ensured not only that there is data there, but I've also made sure the data changes by doing a count on the links array before and after I modify it. </p>
  
  <p>Here is the problem code from my update function.</p>
  
  <pre><code>    link = linkElements.selectAll("path.link") //link elements is dom object that holds my links
      .data(links).enter().append("path")
      .attr("class", "link")
      .attr("d", diagonal);
  
      link.exit().remove();
  </code></pre>
  
  <p>It's practically the same as many examples, but I keep seeing this:</p>
  
  <pre><code>TypeError: link.exit is not a function
  
  link.exit().remove();
  </code></pre>
  
  <p>What is going on? I do something similar with the nodes. I can't get anything to delete from the tree.</p>