Skip to content

Commit

Permalink
remove all children
Browse files Browse the repository at this point in the history
fixes #275
  • Loading branch information
Fil authored and mbostock committed Jun 7, 2021
1 parent 54a3acf commit 1829d8b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/selection/selectChildren.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {childMatcher} from "../matcher.js";
var filter = Array.prototype.filter;

function children() {
return this.children;
return Array.from(this.children);
}

function childrenFilter(match) {
Expand Down
10 changes: 10 additions & 0 deletions test/selection/remove-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,13 @@ it("selection.remove() skips missing elements", "<h1 id='one'></h1><h1 id='two'>
assert.strictEqual(one.parentNode, null);
assert.strictEqual(two.parentNode, document.body);
});

tape("selectChildren().remove() removes all children", function(test) {
var document = jsdom("<div><span>0</span><span>1</span><span>2</span><span>3</span><span>4</span><span>5</span><span>6</span><span>7</span><span>8</span><span>9</span></div>"),
p = document.querySelector("div"),
selection = d3.select(p).selectChildren();
test.equal(selection.size(), 10);
test.equal(selection.remove(), selection);
test.equal(d3.select(p).selectChildren().size(), 0);
test.end();
});

0 comments on commit 1829d8b

Please sign in to comment.