Customize: Link elements
prior to embedding to prevent possible errors when a control is associated with a non-existent section.
Fixes issue specifically with attempting to access an orphaned control's `elements` immediately after it has been added. Normally this would not happen because a control would not be registered without a section, and also a control should only be interacted with once its `embedded` deferred has been resolved. Also harden logic for gathering list of deferred setting IDs. See #37964. Fixes #42330. git-svn-id: https://develop.svn.wordpress.org/trunk@42024 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a33d615433
commit
610b1f05de
@ -3474,12 +3474,18 @@
|
|||||||
}
|
}
|
||||||
_.extend( settings, control.params.settings );
|
_.extend( settings, control.params.settings );
|
||||||
|
|
||||||
// Note: Settings can be an array or an object.
|
// Note: Settings can be an array or an object, with values being either setting IDs or Setting (or Value) objects.
|
||||||
_.each( settings, function( setting, key ) {
|
_.each( settings, function( value, key ) {
|
||||||
if ( _.isObject( setting ) ) { // @todo Or check if instance of api.Setting?
|
var setting;
|
||||||
control.settings[ key ] = setting;
|
if ( _.isObject( value ) && _.isFunction( value.extended ) && value.extended( api.Value ) ) {
|
||||||
} else {
|
control.settings[ key ] = value;
|
||||||
deferredSettingIds.push( setting );
|
} else if ( _.isString( value ) ) {
|
||||||
|
setting = api( value );
|
||||||
|
if ( setting ) {
|
||||||
|
control.settings[ key ] = setting;
|
||||||
|
} else {
|
||||||
|
deferredSettingIds.push( value );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
@ -3500,6 +3506,7 @@
|
|||||||
// Identify the main setting.
|
// Identify the main setting.
|
||||||
control.setting = control.settings['default'] || null;
|
control.setting = control.settings['default'] || null;
|
||||||
|
|
||||||
|
control.linkElements(); // Link initial elements present in server-rendered content.
|
||||||
control.embed();
|
control.embed();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3511,7 +3518,7 @@
|
|||||||
|
|
||||||
// After the control is embedded on the page, invoke the "ready" method.
|
// After the control is embedded on the page, invoke the "ready" method.
|
||||||
control.deferred.embedded.done( function () {
|
control.deferred.embedded.done( function () {
|
||||||
control.linkElements();
|
control.linkElements(); // Link any additional elements after template is rendered by renderContent().
|
||||||
control.setupNotifications();
|
control.setupNotifications();
|
||||||
control.ready();
|
control.ready();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user