Closed KirkMcDonald closed 3 years ago
Good catch! Maybe a solution would be to materialize Array.from(...this.children)
instead of this.children
, because remove calls each with a function which mutates this.children.
I've implemented this in https://github.com/d3/d3-selection/pull/276, it passes all tests but I'm not 100% sure it's the right approach.
For example, given the following HTML:
The expression
d3.select("#content").selectChildren().remove()
will only remove the even-numbered elements. I find this behavior surprising, and would naively expect it to remove all of the<span>
tags.In contrast, the expression
d3.select("#content").selectAll("*").remove()
will remove all of the<span>
tags.