Accepted answer

I would either use a selection filter for this, filtering on the nodeName property of the element:

d3.selectAll("top_level_selector") //or use existing selection from appending
    return this.nodeName == 'circle';
.attr("r", 12);


Or possibly just check inside the attribute function for correct nodetype :

    if(this.nodeName =='circle'){ return 12 }

I'm not positive but I don't think this will present a problem when it tries to assign an "r" attribute of undefined to the non-circle elements (and so on for 'points' on circle, etc).

Related Query