Make WordPress Core

Opened 8 years ago

Closed 5 years ago

#40333 closed defect (bug) (fixed)

TwentySeventeen: customize-controls.js passes unused jQuery argument to an IIFE that accepts no arguments

Reported by: christian1012's profile Christian1012 Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version: 4.7
Component: Bundled Theme Keywords: has-patch
Focuses: javascript Cc:

Description

The IIFE (Immediately Invoked Function Expression) in customize-controls.js looks like this:

(function() {
    // Do stuff
})( jQuery );

In the context of jQuery, this style is used to alias jQuery as $ within the function expression.

Example:

(function( $ ) {
    console.log( $( 'body' ) );
})( jQuery );

jQuery is not used in the function block, nor does the function expression accept an argument, so my recommendation would be to remove it. If there is a reason to pass jQuery as an argument, then the function expression should at least accept it as an argument.

Attachments (2)

40333.0.diff (376 bytes) - added by Christian1012 8 years ago.
40333.1.diff (744 bytes) - added by Hareesh Pillai 5 years ago.
Patch refreshed. Also, handled Twenty Nineteen's customize-controls.js

Download all attachments as: .zip

Change History (9)

#1 @Christian1012
8 years ago

  • Keywords has-patch added

40333.0.diff added.

This ticket was mentioned in Slack in #core-themes by hareesh-pillai. View the logs.


5 years ago

#3 @SergeyBiryukov
5 years ago

  • Milestone changed from Awaiting Review to 5.3
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#4 @SergeyBiryukov
5 years ago

Hi @Christian1012, welcome to WordPress Trac!

Thanks for the ticket and the patch! Sorry it took so long for someone to get back to you.

Looks like this was done for consistency with other files (where $ is used), or maybe as a copy/paste from those files. I have no objections to changing it though.

The same should be done for Twenty Nineteen's customize-controls.js as well.

@Hareesh Pillai
5 years ago

Patch refreshed. Also, handled Twenty Nineteen's customize-controls.js

#5 @williampatton
5 years ago

I took a look at this ticket just now in passing and the patch refresh lgtm :)

#6 @SergeyBiryukov
5 years ago

In 45922:

Twenty Seventeen: Remove unused jQuery argument passed to an IIFE that accepts no arguments.

Props Christian1012, hareesh-pillai.
See #40333.

#7 @SergeyBiryukov
5 years ago

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

In 45923:

Twenty Nineteen: Remove unused jQuery argument passed to an IIFE that accepts no arguments.

Props Christian1012, hareesh-pillai.
Fixes #40333.

Note: See TracTickets for help on using tickets.