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

Invalid type received for "enabled". Expected: bool. Received [boolean] "false" #2500

Closed
eymiha opened this issue Dec 23, 2016 · 6 comments
Closed

Comments

@eymiha
Copy link
Contributor

eymiha commented Dec 23, 2016

Create a network with options = { physics: { enabled: false } } and look at the console output.

This seems to be related to #2452.

@eymiha
Copy link
Contributor Author

eymiha commented Dec 25, 2016

The problem stems from the misuse of the ES6 Object Literal Property Value feature.

in options.js the declaration

let bool = 'boolean';

and subsequent use

enabled: { bool }

is interpreted as

enabled: { bool: 'boolean' }

not

enabled: { 'boolean': 'boolean' }

The fix is to replace the shorthand for the bool property

enabled: { bool }

with

enabled: { boolean: bool }

and all other such uses in options.js.

@mojoaxel mojoaxel added this to the Minor Release v4.18 milestone Dec 25, 2016
eymiha added a commit to eymiha/vis that referenced this issue Dec 25, 2016
eymiha added a commit to eymiha/vis that referenced this issue Dec 25, 2016
yotamberk added a commit that referenced this issue Dec 27, 2016
* Fix redraw order

* Fix error when option is not defined

* Allow template labels

* Fix boolean types bug
@easleydp
Copy link
Contributor

easleydp commented Dec 28, 2016

Concerned that this regresses part of the #2452 fix, i.e. reintroduces use of reserved word boolean. When used as an object literal key, 'boolean' must be quoted (as yotamberk did it in 534ad9f)

PS. Isn't there some linter that could flag this kind of transgression during the build?

@yotamberk
Copy link
Contributor

What if the key is in quotation mark?Will that solve the problem?
The problem with the #2452 fix is that it introduced errors in options with boolean values. It seems that the only way to use your fix without breaking other code is by changing Validator to be able to handle 'bool' instead of 'boolean'. Can you take care of that?

@easleydp
Copy link
Contributor

Yes, if the key (being a reserved word such as boolean) is in quotation marks I believe that will solve the problem. In other words, like you did it in 534ad9f.

If you still think changing Validator is necessary please let me know.

@yotamberk
Copy link
Contributor

I think we can do without changing Validator

@eymiha
Copy link
Contributor Author

eymiha commented Dec 28, 2016

If this is an issue then replacing my changes with { 'boolean' : bool } in option.js should fix the problem.

No change to Validator.js should be needed.

[ I made the changes in #2501 because #2452 was having problems in browsers. Did #2452 work cleanly in any context? The value of typeof true or typeof false is "boolean", which needs to be the option's target - not "bool". ]

@easleydp - since you have access to both environments, can you quote the property and verify the fix on both sides?

mojoaxel pushed a commit that referenced this issue Dec 29, 2016
* element characteristic changes
* assume edge color inheritance is correct before choosing
* Adjust nodes’ chosen’s boolean -> bool
* Need to get user-reset size
* make example edges thicker for more noticeable shadow
* preemptive ES6 fix (see #2500/#2501)
* documentation for the feature that was previously overwritten
yotamberk pushed a commit that referenced this issue Jan 15, 2017
* fix(graph2d): fix #2500 for graph2d; improves #2580

* fix(DataSet): make sure the right id-type is used internaly

This fixes a fixed strange string-number conversion issue.
It can happen that id "0" !== 0 what causes #2580.

fixes #2580
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants