[1] https://observablehq.com/@d3/selection-join
document.getElementById("myRoot").appendChild(svg.node());
and remove the yield
Thats it. But apparently you all don't know this, because you don't want to understand D3 or basic DOM APIs beyond ctrl-c/ctrl-v.
[1] https://observablehq.com/@d3/selection-join