From 00eb9473b2e056995aae1a3a264012d65f41b0ac Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 31 Oct 2017 02:58:42 +0000 Subject: [PATCH] Customize: Consolidate sourcing of control `params`. Prevent needlessly iterating over `controlConstructor` to find `type` when it is already supplied. Amends [41750], [41726]. See #42083. git-svn-id: https://develop.svn.wordpress.org/trunk@42048 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/customize-controls.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 365a99d8d6..a51fb02e10 100644 --- a/src/wp-admin/js/customize-controls.js +++ b/src/wp-admin/js/customize-controls.js @@ -3466,7 +3466,12 @@ initialize: function( id, options ) { var control = this, deferredSettingIds = [], settings, gatherSettings; - control.params = _.extend( {}, control.defaults ); + control.params = _.extend( + {}, + control.defaults, + control.params || {}, // In case sub-class already defines. + options.params || options || {} // The options.params property is deprecated, but it is checked first for back-compat. + ); if ( ! api.Control.instanceCounter ) { api.Control.instanceCounter = 0; @@ -3487,7 +3492,6 @@ } ); } - _.extend( control.params, options.params || options ); if ( ! control.params.content ) { control.params.content = $( '
  • ', { id: 'customize-control-' + id.replace( /]/g, '' ).replace( /\[/g, '-' ),