-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Cleanup mergeOptions() #3280
Cleanup mergeOptions() #3280
Conversation
bradh
left a comment
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.
+1 for the tests.
| * @param {String} option | option key in the options argument | ||
| * @param {object} globalOptions | global options, passed in to determine value of option 'enabled' | ||
| */ | ||
| exports.mergeOptions = function (mergeTarget, options, option, allowDeletion = false, globalOptions = {}) { |
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.
Looks like you're changing the signature. If this was exported, doesn't that make it public API? Perhaps keep the old method (deprecated) and remove later.
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.
This is not a documented API call and is only used internally between the vis components. I therefore have no qualms about changing the signature. I scanned all of the code under lib/, this adjustment is safe.
You get bonus points for your attention, though.
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.
So we do need the export, but only for intra-vis module sharing?
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.
Yes, indeed. The sharing between vis modules also goes for the other source files in the same directory, except DataSet.js and DataView.js. When I squint at them, I actually think that lib/shared would be a better place to put them.
* Fix mergeOptions() and add unit tests * Removed comment
Fixing and testing of method
util.mergeOptions().I wasn't planning on doing this, but in the course of handling another issue, I discovered a bug in
util.mergeOptions()and then the more I looked at it, the more problems I found.I can not unsee this, and therefore I hereby give it a torture test and proper fixing.
To be honest, I'm not sure if this is useful, since ES6 has
Object.assign(), but I don't wantto screw up the expected functionality too much. However,
mergeOptions()has changed a lot.Changes:
allowDeletion, this is not used within the method.networkis zero, because thereallowDeletionis never usednetwork, the impact is smallutil, in particular formergeOptions(). Goals:mergeOptions()globalOptionsand whenglobalOptionsnot present.