Ticket #6764 (closed enhancement: fixed)
Use toggleClass instead of [ bool ? "addClass" : "removeClass" ]
| Reported by: | Xavi | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.9.0 |
| Component: | [meta] ui.dev | Version: | 1.8.7 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Several times in the jquery-ui code base a class is conditionally added to an element using this construct: elem[ bool ? "addClass" : "removeClass" ]("foo"). I propose that `$.fn.toggleClass` be used instead. I feel this change will make the code less verbose and easier to read.
Change History
comment:2 Changed 2 years ago by Xavi
- Status changed from new to closed
- Resolution set to fixed
All: Use .toggleClass() instead of conditionally using .addClass() and .removeClass(). Fixes #6764 - Use toggleClass instead of [ bool ? 'addClass' : 'removeClass' ].
Changeset: 956697bfca1b386ae20eb27ccfd8c1df3234f1f2
Note: See
TracTickets for help on using
tickets.


Pull request: https://github.com/jquery/jquery-ui/pull/77