Customizer Theme Switcher: Don't re-render a theme control if it has already been rendered.

Move initialization of `$customizeSidebar` to `api.ThemesSection.initialize()` to prevent cases where the result can be undefined.

props westonruter, ocean90.
fixes #31793.

git-svn-id: https://develop.svn.wordpress.org/trunk@32119 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2015-04-13 22:09:35 +00:00
parent 17cc95573f
commit 5c1eb9f4f8
1 changed files with 14 additions and 4 deletions

View File

@ -554,7 +554,14 @@
template: '',
screenshotQueue: null,
$window: $( window ),
$customizeSidebar: $( '.wp-full-overlay-sidebar-content:first' ),
/**
* @since 4.2.0
*/
initialize: function () {
this.$customizeSidebar = $( '.wp-full-overlay-sidebar-content:first' );
return api.Section.prototype.initialize.apply( this, arguments );
},
/**
* @since 4.2.0
@ -1951,6 +1958,7 @@
api.ThemeControl = api.Control.extend({
touchDrag: false,
isRendered: false,
/**
* Defer rendering the theme control until the section is displayed.
@ -1961,13 +1969,15 @@
var control = this,
renderContentArgs = arguments;
api.section( control.section(), function ( section ) {
api.section( control.section(), function( section ) {
if ( section.expanded() ) {
api.Control.prototype.renderContent.apply( control, renderContentArgs );
control.isRendered = true;
} else {
section.expanded.bind( function ( expanded ) {
if ( expanded ) {
section.expanded.bind( function( expanded ) {
if ( expanded && ! control.isRendered ) {
api.Control.prototype.renderContent.apply( control, renderContentArgs );
control.isRendered = true;
}
} );
}