D3 Event Issue

https://github.com/d3/d3/issues/2488

by IPWright83

HTML

<svg width="500" height="500"></svg>

JavaScript

function moveToFront(element) {
  d3.select(element).each(function(){
    this.parentNode.appendChild(this);
  });
}

let data = [
	{ x: 250, y: 250, c: "red"}, 
  { x: 300, y: 300, c: "blue"}, 
  { x: 350, y: 350, c: "green"}
];

d3.select("svg")
  .selectAll("circle")
  .data(data)
  .enter()
  .append("circle")
  .attr("cx", function(d) { return d.x; })
  .attr("cy", function(d) { return d.y; })
  .attr("r", 50)
  .style("fill", function(d) { return d.c; })
  .on("click", function() { console.log("click"); })
  .on("mousedown", function() {
    console.log("mousedown");
    moveToFront(this);
  })