Skip to content
This repository was archived by the owner on Jul 29, 2019. It is now read-only.

Conversation

@wimrijnders
Copy link

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 want
to screw up the expected functionality too much. However, mergeOptions() has changed a lot.

Changes:

  • Removed parameter allowDeletion, this is not used within the method.
    • The impact of this removal for all modules except network is zero, because there allowDeletion is never used
    • For network, the impact is small
  • Added unit tests for module util, in particular for mergeOptions(). Goals:
    • validate all paths within method mergeOptions()
    • ensure that incorrect input is handled properly
  • The actual initial fix: missing option value should be handled properly, even when missing in
    globalOptions and when globalOptions not present.

Copy link
Contributor

@bradh bradh left a 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 = {}) {
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

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?

Copy link
Author

@wimrijnders wimrijnders Jul 24, 2017

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.

@yotamberk yotamberk merged commit 2697973 into visjs:develop Jul 23, 2017
@wimrijnders wimrijnders deleted the cleanupMergeOptions branch July 24, 2017 03:24
primozs pushed a commit to primozs/vis that referenced this pull request Jan 3, 2019
* Fix mergeOptions() and add unit tests

* Removed comment
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants