Ticket #6764 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

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

comment:3 Changed 2 years ago by scott.gonzalez

  • Type changed from bug to enhancement
Note: See TracTickets for help on using tickets.