Skip to content

Event listeners arguments should be (event, d) but in some projects are (d, index) #24

@caesarsol

Description

@caesarsol

we had some notifications that in some cases the defined events listeners were called with (d, i) as parameters, and no events.

we are relying on d3-selection (added as a peerDependency) for the event listeners, and after checking I discovered that the problem was caused by which version of d3-selection is used in the project (which is sometimes not strictly linked to which version of d3 is used, unfortunately):

  • in d3-selection v1.4.1 the rule was:

    When a specified event is dispatched on a selected element, the specified listener will be evaluated for the element, being passed the current datum (d), the current index (i), and the current group (nodes)

  • in d3-selection v2.0.0 (and hence v3.0.0) that changed:

    When a specified event is dispatched on a selected element, the specified listener will be evaluated for the element, being passed the current event (event) and the current datum (d)

we will need to:

  1. clear this out in the README
  2. find a reliable solution, maybe backward compatible. possibly add d3-selection as a hard dependency?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions