Skip to content

Commit a32484a

Browse files
committed
do not .classed() layers in ensureSingle if className not given
... which is an improvement over commit 8ca4101
1 parent 296f088 commit a32484a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/lib/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ lib.isD3Selection = function(obj) {
710710
*
711711
* @param {d3 selection} parent : parent selection of the element in question
712712
* @param {string} nodeType : node type of element to append
713-
* @param {string} className : class name of element in question
713+
* @param {string} className (optional) : class name of element in question
714714
* @param {fn} enterFn (optional) : optional fn applied to entering elements only
715715
* @return {d3 selection} selection of new layer
716716
*
@@ -737,7 +737,8 @@ lib.ensureSingle = function(parent, nodeType, className, enterFn) {
737737
var sel = parent.select(nodeType + (className ? '.' + className : ''));
738738
if(sel.size()) return sel;
739739

740-
var layer = parent.append(nodeType).classed(className || '', true);
740+
var layer = parent.append(nodeType);
741+
if(className) layer.classed(className, true);
741742
if(enterFn) layer.call(enterFn);
742743

743744
return layer;

0 commit comments

Comments
 (0)