Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

axis.ticks() returns Arguments object after axis.ticks(count) #2430

Closed
rummelsworth opened this issue May 11, 2015 · 2 comments
Closed

axis.ticks() returns Arguments object after axis.ticks(count) #2430

rummelsworth opened this issue May 11, 2015 · 2 comments
Labels
bug Something isn’t working
Milestone

Comments

@rummelsworth
Copy link

d3.svg.axis().ticks().constructor // function Array() { [native code] }
d3.svg.axis().ticks().toString() // "10"

d3.svg.axis().ticks(10).ticks().constructor // function Object() { [native code] }
d3.svg.axis().ticks(10).ticks().toString() // "[object Arguments]"

This bit me when I was feeding an explicit tick spec of an axis to the underlying scale of the axis to get tick values from the scale to manipulate and then feed back to the axis. scale.ticks did not like the Arguments object, giving me [].

The problem is this line in axis.ticks:

tickArguments_ = arguments;

That line should probably look or at least behave like this:

tickArguments_ = Array.prototype.slice.call(arguments);

In any case, an invocation's arguments object shouldn't be exposed to its callers.

@rummelsworth rummelsworth changed the title axis.ticks() returns non-Array after axis.ticks(count) axis.ticks() returns Arguments object after axis.ticks(count) May 11, 2015
@mbostock mbostock added the bug Something isn’t working label Oct 21, 2015
@mbostock mbostock added this to the 3.5.x milestone Oct 21, 2015
@mbostock
Copy link
Member

Sounds reasonable.

@mbostock mbostock modified the milestones: 3.5.7, 3.5.x Oct 22, 2015
@mbostock
Copy link
Member

Fix merged in #2591.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working
Development

No branches or pull requests

2 participants