-
Notifications
You must be signed in to change notification settings - Fork 0
Fix data binding check #7
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
base: master
Are you sure you want to change the base?
Conversation
* Added lookup table to search commands by value. Fixes plotly#1169
* Test that API command binding accepts data arrays.
This looks great! Unless I'm wrong, it should be able to avoid pathological cases gracefully. The relevant cases seem to be:
|
This PR wouldn't do a deep comparison. Shall I check here whether |
As long as there's no deep comparison, I think it should be fine, but yeah, probably best to stop this at the hasSimpleBindings level. Thanks for cleaning this up! I failed to appreciate the importance of visibility toggles like this. Is this PR intended for the main plotly.js repo? (It'd definitely be a welcome fix!) |
(Hope the code wasn't too difficult to work though! 😄 It was a simple concept that ended up being moderately complicated to actually implement!) |
|
||
if(obj.hasOwnProperty(binding.prop)) { | ||
if(obj[binding.prop] !== value) { | ||
if(!thisCache.hasOwnProperty(binding.prop)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test.
|
||
for(commandIndex in binding.valueByBindings) { | ||
var commandValue = binding.valueByBindings[commandIndex]; | ||
if(commandValue.length !== value.length) continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test
Yes, if you're happy with this solution and the signature change in I guess since plotly#1176 fixes plotly#1169 , there is no rush to merge this PR. I'll talk to you on Slack tomorrow. |
@@ -135,6 +139,39 @@ exports.manageCommandObserver = function(gd, container, commandList, onchange) { | |||
return ret; | |||
}; | |||
|
|||
function getCommandIndex(binding, value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename binding
to observer
@@ -135,6 +139,39 @@ exports.manageCommandObserver = function(gd, container, commandList, onchange) { | |||
return ret; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename ret
to observer
@rreusser @etpinard
This fix changes the signature of
exports.hasSimpleAPICommandBindings = function(gd, commandList, bindingsByValue, valueByBindings)
in a backwards-compatible way (I don't really like the new signature; if compatibility isn't an issue here, I'd passbinding
instead ofbindingsByValue
andvalueByBindings
).This change in signature was introduced so that I could search for bindings when the associated value is an array.