mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Attributes: Use simpler boolean check vs a function call
Ref gh-2491
This commit is contained in:
committed by
Timmy Willison
parent
53f798cf4d
commit
4bf1a09522
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user