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.
Built from https://develop.svn.wordpress.org/trunk@32119


git-svn-id: http://core.svn.wordpress.org/trunk@32098 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2015-04-13 22:10:29 +00:00
parent da928039a6
commit 7b24017cdb
3 changed files with 17 additions and 7 deletions

View File

@ -554,7 +554,14 @@
template: '', template: '',
screenshotQueue: null, screenshotQueue: null,
$window: $( window ), $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 * @since 4.2.0
@ -1951,6 +1958,7 @@
api.ThemeControl = api.Control.extend({ api.ThemeControl = api.Control.extend({
touchDrag: false, touchDrag: false,
isRendered: false,
/** /**
* Defer rendering the theme control until the section is displayed. * Defer rendering the theme control until the section is displayed.
@ -1964,10 +1972,12 @@
api.section( control.section(), function( section ) { api.section( control.section(), function( section ) {
if ( section.expanded() ) { if ( section.expanded() ) {
api.Control.prototype.renderContent.apply( control, renderContentArgs ); api.Control.prototype.renderContent.apply( control, renderContentArgs );
control.isRendered = true;
} else { } else {
section.expanded.bind( function( expanded ) { section.expanded.bind( function( expanded ) {
if ( expanded ) { if ( expanded && ! control.isRendered ) {
api.Control.prototype.renderContent.apply( control, renderContentArgs ); api.Control.prototype.renderContent.apply( control, renderContentArgs );
control.isRendered = true;
} }
} ); } );
} }

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.2-beta4-32118'; $wp_version = '4.2-beta4-32119';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.