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
This commit is contained in:
Weston Ruter 2017-10-31 02:58:42 +00:00
parent 0a964a48f8
commit 00eb9473b2
1 changed files with 6 additions and 2 deletions

View File

@ -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 = $( '<li></li>', {
id: 'customize-control-' + id.replace( /]/g, '' ).replace( /\[/g, '-' ),