Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I’m not sure about this API. It’s nice to have something that can capture the context of a selection.each (or selection.attr, selection.data, etc.). But it’s a bit weird that you have to pass in
arguments
and then have the selection recompute the ancestors.Also, sometimes you might want to access the current group or the parent node within a callback. The selection.context can determine those things, but doesn’t expose them.
Also, within a selection.each (or most other selection methods) callback, you don’t have easy access to the current selection because the
this
context is set to the current element. So maybe an approach like d3.event is more suitable? Like, say, d3.context() could be a magic method that only works within selection.each, and returns the context for the current selection.