Skip to content

protect against a null key in selection #530

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

Merged
merged 2 commits into from
Mar 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: plotly
Title: Create Interactive Web Graphics via 'plotly.js'
Version: 3.4.7
Version: 3.4.8
Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"),
email = "cpsievert1@gmail.com"),
person("Chris", "Parmer", role = c("aut", "cph"),
Expand Down
6 changes: 6 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
3.4.8 -- 23 Mar 2016

BUGFIX:

* Safeguard against null fields in selections. See #530.

3.4.7 -- 19 Mar 2016

BUGFIX:
Expand Down
2 changes: 1 addition & 1 deletion inst/htmlwidgets/plotly.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ HTMLWidgets.widget({
var tr = x.data[pt.curveNumber];
// add on additional trace info, if it exists
attachKey = function(keyName) {
if (tr.hasOwnProperty(keyName)) {
if (tr.hasOwnProperty(keyName) && tr[keyName] !== null) {
if (typeof pt.pointNumber === "number") {
obj[keyName] = tr[keyName][pt.pointNumber];
} else {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was having trouble running https://gist.github.com/walkerke/da941dac84f730adcdde locally and discovered that it was because key is defined, but null (a result of recent changes to the R client). This provides a safer check before trying to subset trace info.

@timelyportfolio I'm a JS novice, so if you see anything in inst/htmlwidgets/plotly.js that could be improved, please let me know :)

Expand Down