diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2015-10-14 15:07:53 -0400 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2015-10-25 15:00:51 -0400 |
commit | c003cd6bc8336927dad70889ee24e176f90b25a9 (patch) | |
tree | 06b41db5a0bcedb5ddb0d94d33a8643756ab1200 /src | |
parent | f24726daa3760014b7283ad14a13117c72dd9474 (diff) | |
download | jquery-c003cd6bc8336927dad70889ee24e176f90b25a9.tar.gz jquery-c003cd6bc8336927dad70889ee24e176f90b25a9.zip |
Attributes: Use simpler boolean check vs a function call
Ref gh-2491
(cherry picked from commit 4bf1a09522955eb52de1fafb4ee1ecc5982b7a3e)
Diffstat (limited to 'src')
-rw-r--r-- | src/attributes/classes.js | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/attributes/classes.js b/src/attributes/classes.js index 1d24a1851..15a37bc99 100644 --- a/src/attributes/classes.js +++ b/src/attributes/classes.js @@ -100,10 +100,7 @@ jQuery.fn.extend( { toggleClass: function( value, stateVal ) { var type = typeof value, - classNames = type === "string" ? value.match( rnotwhite ) : "", - checker = typeof stateVal === "boolean" ? - function() { return !stateVal; } : - jQuery.fn.hasClass; + classNames = type === "string" ? value.match( rnotwhite ) : []; return this.each( function( i ) { var className, @@ -118,7 +115,7 @@ jQuery.fn.extend( { // Toggle individual class names based on presence or stateVal while ( ( className = classNames[ c++ ] ) ) { - if ( checker.call( self, className ) ) { + if ( stateVal === false || stateVal !== true && self.hasClass( className ) ) { self.removeClass( className ); } else { self.addClass( className ); |