Skip to content

Commit ce00a3c

Browse files
committed
Fix #209.
1 parent e2b3d37 commit ce00a3c

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

src/selectAll.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import {Selection, root} from "./selection/index";
33
export default function(selector) {
44
return typeof selector === "string"
55
? new Selection([document.querySelectorAll(selector)], [document.documentElement])
6-
: new Selection([selector == null ? [] : selector], root);
6+
: new Selection([selector == null ? [] : Array.from(selector)], root);
77
}

test/selectAll-test.js

+10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ tape("d3.selectAll(…) returns an instanceof d3.selection", function(test) {
88
test.end();
99
});
1010

11+
tape("d3.selectAll(…) accepts an iterable", function(test) {
12+
var document = global.document = jsdom("<h1>hello</h1>");
13+
try {
14+
test.deepEqual(d3.selectAll(new Set([document])).nodes(), [document]);
15+
test.end();
16+
} finally {
17+
delete global.document;
18+
}
19+
});
20+
1121
tape("d3.selectAll(string) selects all elements that match the selector string, in order", function(test) {
1222
var document = global.document = jsdom("<h1 id='one'>foo</h1><h1 id='two'>bar</h1>");
1323
try {

test/selection/dispatch-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ tape("selection.dispatch(type) skips missing elements", function(test) {
6262
two = document.querySelector("#two"),
6363
selection = d3.selectAll([, one,, two]).datum(function(d, i) { return "node-" + i; }).on("bang", function(d, i, nodes) { event = d3.event; result.push(this, d, i, nodes); });
6464
test.equal(selection.dispatch("bang"), selection);
65-
test.deepEqual(result, [one, "node-1", 1, [, one,, two], two, "node-3", 3, [, one,, two]]);
65+
test.deepEqual(result, [one, "node-1", 1, [undefined, one, undefined, two], two, "node-3", 3, [undefined, one, undefined, two]]);
6666
test.equal(event.type, "bang");
6767
test.equal(event.detail, null);
6868
test.end();

test/selection/each-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ tape("selection.each(function) skips missing elements", function(test) {
2020
two = document.querySelector("#two"),
2121
selection = d3.selectAll([, one,, two]).datum(function(d, i) { return "node-" + i; });
2222
test.equal(selection.each(function(d, i, nodes) { result.push(this, d, i, nodes); }), selection);
23-
test.deepEqual(result, [one, "node-1", 1, [, one,, two], two, "node-3", 3, [, one,, two]]);
23+
test.deepEqual(result, [one, "node-1", 1, [undefined, one, undefined, two], two, "node-3", 3, [undefined, one, undefined, two]]);
2424
test.end();
2525
});

test/selection/on-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ tape("selection.on(type, listener) passes the listener the index as of registrat
210210
one = document.querySelector("#one"),
211211
selection = d3.selectAll([, one]).on("click", function(d, i) { result = i; });
212212
selection.dispatch("click");
213-
test.deepEqual(selection, {_groups: [[, one]], _parents: [null]});
213+
test.deepEqual(selection, {_groups: [[undefined, one]], _parents: [null]});
214214
test.equal(result, 1);
215215
selection = selection.sort().dispatch("click");
216216
test.deepEqual(selection, {_groups: [[one, ]], _parents: [null]});

0 commit comments

Comments
 (0)