Skip to content

Commit 1829d8b

Browse files
Filmbostock
authored andcommitted
remove all children
fixes #275
1 parent 54a3acf commit 1829d8b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/selection/selectChildren.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {childMatcher} from "../matcher.js";
33
var filter = Array.prototype.filter;
44

55
function children() {
6-
return this.children;
6+
return Array.from(this.children);
77
}
88

99
function childrenFilter(match) {

test/selection/remove-test.js

+10
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,13 @@ it("selection.remove() skips missing elements", "<h1 id='one'></h1><h1 id='two'>
2929
assert.strictEqual(one.parentNode, null);
3030
assert.strictEqual(two.parentNode, document.body);
3131
});
32+
33+
tape("selectChildren().remove() removes all children", function(test) {
34+
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>"),
35+
p = document.querySelector("div"),
36+
selection = d3.select(p).selectChildren();
37+
test.equal(selection.size(), 10);
38+
test.equal(selection.remove(), selection);
39+
test.equal(d3.select(p).selectChildren().size(), 0);
40+
test.end();
41+
});

0 commit comments

Comments
 (0)