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

jQuery.stop: Unnecessary conditional statement #4374

Closed
wonseop opened this issue Apr 29, 2019 · 3 comments · Fixed by #4375
Closed

jQuery.stop: Unnecessary conditional statement #4374

wonseop opened this issue Apr 29, 2019 · 3 comments · Fixed by #4375

Comments

@wonseop
Copy link
Contributor

@wonseop wonseop commented Apr 29, 2019

Description

I found strange code in line 545 of 'src/effect.js'.
The variable 'type' in this code can not be false.
Therefore, it would be better to modify the conditional statement.

	stop: function( type, clearQueue, gotoEnd ) {
		var stopQueue = function( hooks ) {
			var stop = hooks.stop;
			delete hooks.stop;
			stop( gotoEnd );
		};

		if ( typeof type !== "string" ) {    // <-- Valiable 'type' has a string value or 'undefined'
			gotoEnd = clearQueue;
			clearQueue = type;
			type = undefined;
		}
		if ( clearQueue && type !== false ) { // 'type !== false' is boolean check
                                                                           // It should be compared with 'string' type or 'undefined'
			this.queue( type || "fx", [] );
		}

Link to test case

N/A

@mgol
Copy link
Member

@mgol mgol commented May 1, 2019

PR: #4375

@mgol mgol closed this as completed in #4375 May 1, 2019
mgol pushed a commit that referenced this issue May 1, 2019
Because of the above conditional, the 'type' variable has a value of type
'string' or undefined. Therefore, boolean comparisons for 'type' variable
is always unnecessary because it return true. The patch removed the
unnecessary conditional statement.

Fixes gh-4374
Closes gh-4375
mgol pushed a commit that referenced this issue Sep 25, 2019
Because of the above conditional, the 'type' variable has a value of type
'string' or undefined. Therefore, boolean comparisons for 'type' variable
is always unnecessary because it return true. The patch removed the
unnecessary conditional statement.

Fixes gh-4374
Closes gh-4375

(cherry picked from commit 110802c)
@mgol
Copy link
Member

@mgol mgol commented Sep 26, 2019

Cherry-picked PR #4375 to 3.x-stable in 30f5c6c.

@mgol mgol removed this from the 4.0.0 milestone Sep 26, 2019
@mgol mgol added this to the 3.5.0 milestone Sep 26, 2019
@alnzialiksav

This comment has been minimized.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging a pull request may close this issue.

3 participants