aboutsummaryrefslogtreecommitdiffstats
path: root/src/attributes/classes.js
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2015-10-14 15:07:53 -0400
committerTimmy Willison <timmywillisn@gmail.com>2015-10-18 12:39:38 -0400
commit4bf1a09522955eb52de1fafb4ee1ecc5982b7a3e (patch)
tree2fcab93f0dfa9e9c5be41517e397efff62bfe647 /src/attributes/classes.js
parent53f798cf4d783bb813b4d1ba97411bc752b275f3 (diff)
downloadjquery-4bf1a09522955eb52de1fafb4ee1ecc5982b7a3e.tar.gz
jquery-4bf1a09522955eb52de1fafb4ee1ecc5982b7a3e.zip
Attributes: Use simpler boolean check vs a function call
Ref gh-2491
Diffstat (limited to 'src/attributes/classes.js')
-rw-r--r--src/attributes/classes.js7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/attributes/classes.js b/src/attributes/classes.js
index 5308ad463..4a6ea3b2e 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 );