From 5283d55271b7146f12ef2b0a589721f229ce51a4 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Tue, 31 Mar 2015 22:20:13 +0000 Subject: [PATCH] Customizer: Defer rendering theme controls until the section is displayed. see #31793. git-svn-id: https://develop.svn.wordpress.org/trunk@31944 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/customize-controls.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 380a722591..ec61263877 100644 --- a/src/wp-admin/js/customize-controls.js +++ b/src/wp-admin/js/customize-controls.js @@ -1859,6 +1859,28 @@ touchDrag: false, + /** + * Defer rendering the theme control until the section is displayed. + * + * @since 4.2.0 + */ + renderContent: function () { + var control = this, + renderContentArgs = arguments; + + api.section( control.section(), function ( section ) { + if ( section.expanded() ) { + api.Control.prototype.renderContent.apply( control, renderContentArgs ); + } else { + section.expanded.bind( function ( expanded ) { + if ( expanded ) { + api.Control.prototype.renderContent.apply( control, renderContentArgs ); + } + } ); + } + } ); + }, + /** * @since 4.2.0 */