Skip to content

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

Closed

Description

@rummelsworth
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.

Activity

  1. changed the title [-]axis.ticks() returns non-Array after axis.ticks(count)[/-] [+]axis.ticks() returns Arguments object after axis.ticks(count)[/+] on May 11, 2015
  2. added
    bug
    on Oct 21, 2015
  3. added this to the 3.5.x milestone on Oct 21, 2015
  4. mbostock commented on Oct 21, 2015

    @mbostock
    Member

    Sounds reasonable.

  5. modified the milestones: 3.5.7, 3.5.x on Oct 22, 2015
  6. added a commit that references this issue on Oct 22, 2015
    e06d041
  7. mbostock commented on Oct 22, 2015

    @mbostock
    Member

    Fix merged in #2591.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions