Bug Tracker

Opened 11 years ago

Closed 11 years ago

#10777 closed bug (invalid)

.toggleClass( className, switch ) works incorectly with non-bool type 'switch' argument

Reported by: San4es Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7
Keywords: Cc:
Blocked by: Blocking:


When you use non-bool "switch" argument .toggleClass works incorrectly in some cases:

.toggleClass(className, true) != .toggleClass(className, 1) .toggleClass(className, 0) != .toggleClass(className, false)

I consider that this function should work as stated in the documentation, as

if (addOrRemove) {

I tests all version of jquery.

Examples here: http://jsfiddle.net/f2NU3/

Change History (1)

comment:1 Changed 11 years ago by dmethvin

Resolution: invalid
Status: newclosed

Quote from the documentation,

A Boolean (not just truthy/falsy) value to determine whether the class should be added or removed. -- http://api.jquery.com/toggleClass/

There is a jQuery UI extension that accepts a number as its second parameter.


Note: See TracTickets for help on using tickets.