Make WordPress Core

Opened 5 years ago

Last modified 3 years ago

#38809 new defect (bug)

Better wp namespace in password-strength-meter.js

Reported by: afercia Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch
Focuses: javascript Cc:


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

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

var passwordStrength;
	wp.passwordStrength = {


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 (4)

#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.

3 years ago

#3 @lemacarl
3 years ago

  • Keywords has-patch added; needs-patch removed

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

Note: See TracTickets for help on using tickets.