d3 / d3-selection

Transform the DOM by selecting elements and joining to data.

Home Page:https://d3js.org/d3-selection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Raise an error when passing a `selection.data()` key that does not evaluate to a string.

mjmdavis opened this issue · comments

As a naive user, I've fallen into the trap of passing an object a few times and d3 doesn't complain and 'kind of' works but the behaviour is not what I intended.

Adding a check might save some people similar confusion.

Values are coerced to a string (e.g., dates), so it would be far too strict to throw an error for all objects. We could specifically test for “[object Object]”, but I think that would be overly precise and also prone to false positives.