Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#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:
Blocked by: Blocking:

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 (3)

comment:2 Changed 9 years ago by Xavi

Resolution: fixed
Status: newclosed

All: Use .toggleClass() instead of conditionally using .addClass() and .removeClass(). Fixes #6764 - Use toggleClass instead of [ bool ? 'addClass' : 'removeClass' ].

Changeset: 956697bfca1b386ae20eb27ccfd8c1df3234f1f2

comment:3 Changed 9 years ago by Scott González

Type: bugenhancement
Note: See TracTickets for help on using tickets.