WordPress.org

Make WordPress Core

Changeset 33134


Ignore:
Timestamp:
07/08/2015 08:41:18 PM (4 years ago)
Author:
westonruter
Message:

Customizer: Defer listening to nav menu setting changes until active.

Defer the preview starting to listen to setting changes until after the Customizer has synced settings into the preview. This ensures that any differences between the JS and PHP representations of the settings won't cause an infinite refresh.

See #32911.
Fixes #32894.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/customize-preview-nav-menus.js

    r32806 r33134  
    1010        renderNoncePostKey: null,
    1111        previewCustomizeNonce: null,
    12         previewReady: $.Deferred(),
    1312        requestUri: '/',
    1413        theme: {
     
    2120
    2221    api.bind( 'preview-ready', function() {
    23         self.previewReady.resolve();
    24     } );
    25     self.previewReady.done( function() {
    26         self.init();
     22        api.preview.bind( 'active', function() {
     23            self.init();
     24        } );
    2725    } );
    2826
     
    3735        }
    3836
    39         self.previewReady.done( function() {
    40             api.each( function( setting, id ) {
     37        api.each( function( setting, id ) {
     38            setting.id = id;
     39            self.bindListener( setting );
     40        } );
     41
     42        api.preview.bind( 'setting', function( args ) {
     43            var id, value, setting;
     44            args = args.slice();
     45            id = args.shift();
     46            value = args.shift();
     47            if ( ! api.has( id ) ) {
     48                // Currently customize-preview.js is not creating settings for dynamically-created settings in the pane; so we have to do it
     49                setting = api.create( id, value ); // @todo This should be in core
    4150                setting.id = id;
    42                 self.bindListener( setting );
    43             } );
    44 
    45             api.preview.bind( 'setting', function( args ) {
    46                 var id, value, setting;
    47                 args = args.slice();
    48                 id = args.shift();
    49                 value = args.shift();
    50                 if ( ! api.has( id ) ) {
    51                     // Currently customize-preview.js is not creating settings for dynamically-created settings in the pane; so we have to do it
    52                     setting = api.create( id, value ); // @todo This should be in core
    53                     setting.id = id;
    54                     if ( self.bindListener( setting ) ) {
    55                         setting.callbacks.fireWith( setting, [ setting(), setting() ] );
    56                     }
     51                if ( self.bindListener( setting ) ) {
     52                    setting.callbacks.fireWith( setting, [ setting(), null ] );
    5753                }
    58             } );
     54            }
    5955        } );
    6056    };
Note: See TracChangeset for help on using the changeset viewer.