Ticket #6889 (closed enhancement: wontfix)
the second parameter of toggleClass() should be allowed to be non-boolean
|Reported by:||waltertross||Owned by:|
|Keywords:||Cc:||kswedberg, paulirish, SlexAxton|
var modif = $('#x').hasClass('xModif') OR $('#y').find('.yModif').length;
(please replace the OR with a double vertical bar, which the tracking system refuses to display)
This example doesn't work currently, unless one replaces length with length > 0, because modif will be true if hasClass() returns true, but it will be an integer otherwise, and toggleClass() currently only uses the second parameter if it is of boolean type.
This example is particularly tricky, because many people tend to think that the OR condition always produces a boolean, and because it will not fail in all cases.
The suggested enhancement is to ignore the second parameter of toggleClass() only if it is undefined, converting it to boolean otherwise.
Alternatively, a big warning in the documentation is suggested.
- Cc kswedberg, paulirish, SlexAxton added
- Priority set to low
- Status changed from new to open
- Milestone changed from 1.4.3 to 1.5
- Keywords needsdocs added
- Status changed from open to closed
- Resolution set to wontfix