v4 .attr() fails silently with multiple arguments
See original GitHub issueHi,
Firstly, thanks for the great library!
I’m pretty new to d3 so sorry if this issue has been discussed somewhere else.
In my d3 v3 code (using coffeescript), I have a lot of attr() calls with multiple values:
svg.append("line").attr
"class" : "date-line"
"y1" : 0
"y2" : height
I just started migrating my code today to v4.1.0 and these lines don’t produce errors but they also don’t do anything. The only way I can get them to work is to go back to one set of values per attr() call:
svg.append("line")
.attr("class", "date-line")
.attr("y1", 0)
.attr("y2", height)
I couldn’t find any reference to this in the api docs or in any other open issues for v4. I’m not sure if this change is by design or a bug but it might be worth mentioning it in the release notes.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Attribute may silently crash · Issue #3769 - GitHub
IntelliSenese work for Param1 and don't work for Param2 with error message or IntelliSenese don't work for both parameters with appropriate ...
Read more >How can you set class attributes from variable arguments ...
that takes a variable number of arguments and then sets them as class attributes conditionally.
Read more >8 Conditions | Advanced R - Hadley Wickham
Section 8.4 introduces the condition object, and the two fundamental tools of condition handling: tryCatch() for error conditions, and withCallingHandlers() ...
Read more >The 10 Most Common JavaScript Issues Developers Face
If you need help figuring out why your JavaScript isn't working, consult this list of the 10 most common JavaScript issues from a...
Read more >Built-in Exceptions — Python 3.11.1 documentation
This exception is raised when a system function returns a system-related error, including I/O failures such as “file not found” or “disk full”...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks, That paragraph makes perfect sense now that I understand. Being a bit of a noob I probably needed something like:
“In v4.0 attr(), style() and property() will not work with multiple values. You now need to add d3-selection-multi and use attrs(), styles() and properties().”
No need to change it though, I think it’s just me. I’ve been using attr() with multiple values so much, I didn’t even consider that you would remove it from the default behaviour. Even though you said quite clearly that you had.
I’ll be sure to use the google group for questions like this in the future.
I’m having a ball with d3, keep up the great work! Hopefully I’ll be able to contribute something back one day.
See the last paragraph of the release notes on d3-selection, which says: