The devil is in the details when it comes to using d3.getBBox();

When using it on a text element created by d3, you must first use .d3.node() to get the true elements for get BBox to process:

Also of note is that getBBox will not function properly on a text elements, or maybe any element, unless it is a child of the group. It cannot be added straight to the SVG element.

var headline = svg.append(“text”)
.attr(“x”, 50)
.attr(“id”, “headline”)
.classed(“gfx-head”, true)
.attr(“y”, function() {
var textNode = d3.select(this);
var textHeight = textNode.node().getBBox().height;
return textHeight;
.call(textEdit, “headline”)