Skip to content
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

Very subtle logic error here #161

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PhilArtin
Copy link

This won't affect most people in day-to-day usage, but this logic is incorrect. Without the parentheses around the ternary operator, EVERYTHING up to the "?" in the ternary operator will be evaluated as a single logic check. That is, "values.min >= this.props.minValue && values.max <= this.props.maxValue && this.props.allowSameValues" are all evaluated as the logic check of the ternary operator. This isn't the intent, I'm sure. I can cause this method to return true even when it shouldn't. For instance, change minValue to be minValue + 1 and maxValue to be maxValue - 1 and then move the slider to minValue on the track. It shouldn't work, but it does. Similarly, move the slider to maxValue on the track and it'll still work even though it shouldn't. Putting parentheses around the ternary expression fixes this and causes the proper behavior.

This won't affect most people in day-to-day usage, but this logic is incorrect. Without the parentheses around the ternary operator, EVERYTHING up to the "?" in the ternary operator will be evaluated as a single logic check. That is, "values.min >= this.props.minValue && values.max <= this.props.maxValue && this.props.allowSameValues" are all evaluated as the logic check of the ternary operator. This isn't the intent, I'm sure. I can cause this method to return true even when it shouldn't. For instance, change minValue to be minValue + 1 and maxValue to be maxValue - 1 and then move the slider to minValue on the track. It shouldn't work, but it does. Similarly, move the slider to maxValue on the track and it'll still work even though it shouldn't. Putting parentheses around the ternary expression fixes this and causes the proper behavior.
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.

1 participant