-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remove all children fixes #275 * more defensive copy selectAll * comment array Co-authored-by: Mike Bostock <mbostock@gmail.com>
- Loading branch information
Showing
6 changed files
with
33 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
export default function(x) { | ||
return typeof x === "object" && "length" in x | ||
? x // Array, TypedArray, NodeList, array-like | ||
: Array.from(x); // Map, Set, iterable, string, or anything else | ||
// Given something array like (or null), returns something that is strictly an | ||
// array. This is used to ensure that array-like objects passed to d3.selectAll | ||
// or selection.selectAll are converted into proper arrays when creating a | ||
// selection; we don’t ever want to create a selection backed by a live | ||
// HTMLCollection or NodeList. However, note that selection.selectAll will use a | ||
// static NodeList as a group, since it safely derived from querySelectorAll. | ||
export default function array(x) { | ||
return x == null ? [] : Array.isArray(x) ? x : Array.from(x); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters