WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 5 weeks ago

#38809 new defect (bug)

Better wp namespace in password-strength-meter.js

Reported by: afercia Owned by:
Milestone: 5.9 Priority: normal
Severity: normal Version:
Component: Administration Keywords: needs-refresh
Focuses: javascript Cc:

Description

Currently, password-strength-meter.js uses this pattern to pass the wp object as argument:

window.wp = window.wp || {};

var passwordStrength;
(function($){
	wp.passwordStrength = {
...

})(jQuery);

so wp inside the IIFE is, technically, undefined, even if WordPress considers wp a global object. Also the first line is pointless if then window.wp is not passed as argument.

Attachments (1)

38809.diff (401 bytes) - added by lemacarl 3 years ago.

Download all attachments as: .zip

Change History (5)

#1 @andg
5 years ago

Invoking a typeof on the wp variable in the IIFE actually returns "object", not "undefined", since any variable not otherwise found is attributed to the global window object by default by the browser.

But yeah, passing it as a second argument would remove all uncertainties, and would probably be a better approach overall.

@lemacarl
3 years ago

#3 @lemacarl
3 years ago

  • Keywords has-patch added; needs-patch removed

@afercia Removed window.wp = window.wp || {}; since its pointless

#4 @Hareesh Pillai
5 weeks ago

  • Keywords needs-refresh added; has-patch removed
  • Milestone changed from Future Release to 5.9
Note: See TracTickets for help on using tickets.