Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#42867 closed defect (bug) (fixed)

HTML Widget: toggleClass() should be passed true/false as second param

Reported by: icaleb's profile iCaleb Owned by: westonruter's profile westonruter
Milestone: 4.9.2 Priority: normal
Severity: normal Version: 4.9
Component: Widgets Keywords: has-patch needs-testing
Focuses: Cc:

Description

http://api.jquery.com/toggleclass/

It expects either true or false for the second parameter, passing an integer will just toggle on/off which is sometimes not the desired result.

Found the problem here: https://github.com/WordPress/WordPress/blob/4.9-branch/wp-admin/js/widgets/custom-html-widgets.js#L207, with correct usage found here: https://github.com/WordPress/WordPress/blob/4.9-branch/wp-admin/js/theme-plugin-editor.js#L365

Attachments (1)

42867.diff (680 bytes) - added by iCaleb 6 years ago.

Download all attachments as: .zip

Change History (8)

@iCaleb
6 years ago

#1 @Presskopp
6 years ago

  • Keywords has-patch needs-testing added

#2 @westonruter
6 years ago

  • Milestone changed from Awaiting Review to 4.9.2
  • Version changed from trunk to 4.9

This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.


6 years ago

#4 @westonruter
6 years ago

  • Owner set to westonruter
  • Status changed from new to reviewing

#5 in reply to: ↑ description @SergeyBiryukov
6 years ago

Replying to iCaleb:

It expects either true or false for the second parameter, passing an integer will just toggle on/off which is sometimes not the desired result.

Confirmed, toggleClass( ..., 0 ) is not the same as toggleClass( ..., false ), and just acts as a regular toggle. Likewise, toggleClass( ..., 1 ) is not the same as toggleClass( ..., true ).

#6 @SergeyBiryukov
6 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 42457:

Widgets: When checking for errors in Custom HTML widget, pass correct value to toggleClass() for Save button.

toggleClass() expects a boolean as a second argument, not an integer.

Props iCaleb.
Fixes #42867.

#7 @SergeyBiryukov
6 years ago

In 42458:

Widgets: When checking for errors in Custom HTML widget, pass correct value to toggleClass() for Save button.

toggleClass() expects a boolean as a second argument, not an integer.

Props iCaleb.
Merges 42457 to the 4.9 branch.
Fixes #42867.

Note: See TracTickets for help on using tickets.