title: D3 with custom element: TypeError: t is null
body: <p>I'm trying to use D3 v.4 with a canvas element (following the pattern introduced <a href="https://medium.freecodecamp.com/d3-and-canvas-in-3-steps-8505c8b27444" rel="nofollow noreferrer">here</a>). I want to bind my data to a custom element, so that it is accessible in memory but isn't rendered to the page like an svg. However, the code below throws: <code>TypeError: t is null</code>. I can't get a good stack trace on the error.</p>
  
  <pre><code>const data = [{a:1,b:2},{a:2,b:4}]; 
  
  const dataContainer = document.createElement('custom');
  const container = d3.select(dataContainer)
        .data(data).enter()
        .append('custom')
        .attr('class','element')
        .attr('test-data-attribute', (d) =&gt; { return d; });
  
  const nodes = container.selectAll('.element');
  console.log(nodes.length);
  </code></pre>
  
  <p>Codepen demo here: <a href="https://codepen.io/jaredsk/pen/OgPMpL?editors=0010" rel="nofollow noreferrer">https://codepen.io/jaredsk/pen/OgPMpL?editors=0010</a> Thanks in advance!</p>