WordPress.org

Make WordPress Core

Opened 21 months ago

Closed 19 months ago

Last modified 19 months ago

#42867 closed defect (bug) (fixed)

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

Reported by: iCaleb Owned by: 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 21 months ago.

Download all attachments as: .zip

Change History (8)

@iCaleb
21 months ago

#1 @Presskopp
21 months ago

  • Keywords has-patch needs-testing added

#2 @westonruter
20 months 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.


19 months ago

#4 @westonruter
19 months ago

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

#5 in reply to: ↑ description @SergeyBiryukov
19 months 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
19 months 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
19 months 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.