Make WordPress Core

Ticket #37032: 37032.3.diff

File 37032.3.diff, 2.4 KB (added by westonruter, 9 years ago)
  • src/wp-admin/js/customize-controls.js

    diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
    index 56c061f..b43c1df 100644
     
    42994299                        var previewer = this, synced = {}, constructs;
    43004300
    43014301                        synced.settings = api.get();
     4302                        synced['settings-modified-while-loading'] = previewer.settingsModifiedWhileLoading;
    43024303                        if ( 'resolved' !== previewer.deferred.active.state() || previewer.loading ) {
    43034304                                synced.scroll = previewer.scroll;
    43044305                        }
     
    44214422                 * Refresh the preview seamlessly.
    44224423                 */
    44234424                refresh: function() {
    4424                         var previewer = this;
     4425                        var previewer = this, onSettingChange;
    44254426
    44264427                        // Display loading indicator
    44274428                        previewer.send( 'loading-initiated' );
     
    44354436                                container:  previewer.container
    44364437                        });
    44374438
     4439                        previewer.settingsModifiedWhileLoading = {};
     4440                        onSettingChange = function( setting ) {
     4441                                previewer.settingsModifiedWhileLoading[ setting.id ] = true;
     4442                        };
     4443                        api.bind( 'change', onSettingChange );
     4444                        previewer.loading.always( function() {
     4445                                api.unbind( 'change', onSettingChange );
     4446                        } );
     4447
    44384448                        previewer.loading.done( function( readyData ) {
    44394449                                var loadingFrame = this, previousPreview, onceSynced;
    44404450
  • src/wp-includes/js/customize-preview.js

    diff --git src/wp-includes/js/customize-preview.js src/wp-includes/js/customize-preview.js
    index 484ccf4..009ec3a 100644
     
    654654                });
    655655
    656656                api.preview.bind( 'sync', function( events ) {
     657
     658                        /*
     659                         * Delete any settings that already exist locally which haven't been
     660                         * modified in the pane while the preview was loading. This prevents
     661                         * situations where the JS value being synced from the pane may differ
     662                         * from the PHP-sanitized JS value in the preview which causes the
     663                         * non-sanitized JS value to clobber the PHP-sanitized value. This
     664                         * is particularly important for selective refresh partials that
     665                         * have a fallback refresh behavior since infinite refreshing would
     666                         * result.
     667                         */
     668                        if ( events.settings && events['settings-modified-while-loading'] ) {
     669                                _.each( _.keys( events.settings ), function( syncedSettingId ) {
     670                                        if ( api.has( syncedSettingId ) && ! events['settings-modified-while-loading'][ syncedSettingId ] ) {
     671                                                delete events.settings[ syncedSettingId ];
     672                                        }
     673                                } );
     674                        }
     675
    657676                        $.each( events, function( event, args ) {
    658677                                api.preview.trigger( event, args );
    659678                        });