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

Conversation

cpsievert
Copy link
Collaborator

No description provided.

@@ -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 :)

@cpsievert
Copy link
Collaborator Author

@cpsievert cpsievert merged commit 0f05881 into master Mar 23, 2016
@timelyportfolio
Copy link
Collaborator

Makes sense. The most painful that I found are the undefined, so I try to protect by insuring all are at least NULL/null. I will do a more thorough review soon, but I think you did well :)

@cpsievert cpsievert deleted the fix/nullSelection branch April 12, 2016 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants