Customize: Prevent syncing unmodified settings from controls into preview to guard against triggering an infinite reload due to selective refresh fallback behavior.
If a value is sanitized in PHP and differs from the JS value in the pane, a `change` event for the setting is triggered upon refresh. This should be avoided since the value just came from the server as being sanitized. This also fixes periodic issue where selective refresh happens immediately after a full refresh. Fixes #37032. Built from https://develop.svn.wordpress.org/trunk@39112 git-svn-id: http://core.svn.wordpress.org/trunk@39054 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
721cf281a3
commit
985a1f6a97
|
@ -4299,6 +4299,7 @@
|
||||||
var previewer = this, synced = {}, constructs;
|
var previewer = this, synced = {}, constructs;
|
||||||
|
|
||||||
synced.settings = api.get();
|
synced.settings = api.get();
|
||||||
|
synced['settings-modified-while-loading'] = previewer.settingsModifiedWhileLoading;
|
||||||
if ( 'resolved' !== previewer.deferred.active.state() || previewer.loading ) {
|
if ( 'resolved' !== previewer.deferred.active.state() || previewer.loading ) {
|
||||||
synced.scroll = previewer.scroll;
|
synced.scroll = previewer.scroll;
|
||||||
}
|
}
|
||||||
|
@ -4421,7 +4422,7 @@
|
||||||
* Refresh the preview seamlessly.
|
* Refresh the preview seamlessly.
|
||||||
*/
|
*/
|
||||||
refresh: function() {
|
refresh: function() {
|
||||||
var previewer = this;
|
var previewer = this, onSettingChange;
|
||||||
|
|
||||||
// Display loading indicator
|
// Display loading indicator
|
||||||
previewer.send( 'loading-initiated' );
|
previewer.send( 'loading-initiated' );
|
||||||
|
@ -4435,6 +4436,15 @@
|
||||||
container: previewer.container
|
container: previewer.container
|
||||||
});
|
});
|
||||||
|
|
||||||
|
previewer.settingsModifiedWhileLoading = {};
|
||||||
|
onSettingChange = function( setting ) {
|
||||||
|
previewer.settingsModifiedWhileLoading[ setting.id ] = true;
|
||||||
|
};
|
||||||
|
api.bind( 'change', onSettingChange );
|
||||||
|
previewer.loading.always( function() {
|
||||||
|
api.unbind( 'change', onSettingChange );
|
||||||
|
} );
|
||||||
|
|
||||||
previewer.loading.done( function( readyData ) {
|
previewer.loading.done( function( readyData ) {
|
||||||
var loadingFrame = this, previousPreview, onceSynced;
|
var loadingFrame = this, previousPreview, onceSynced;
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -654,6 +654,25 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
api.preview.bind( 'sync', function( events ) {
|
api.preview.bind( 'sync', function( events ) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Delete any settings that already exist locally which haven't been
|
||||||
|
* modified in the controls while the preview was loading. This prevents
|
||||||
|
* situations where the JS value being synced from the pane may differ
|
||||||
|
* from the PHP-sanitized JS value in the preview which causes the
|
||||||
|
* non-sanitized JS value to clobber the PHP-sanitized value. This
|
||||||
|
* is particularly important for selective refresh partials that
|
||||||
|
* have a fallback refresh behavior since infinite refreshing would
|
||||||
|
* result.
|
||||||
|
*/
|
||||||
|
if ( events.settings && events['settings-modified-while-loading'] ) {
|
||||||
|
_.each( _.keys( events.settings ), function( syncedSettingId ) {
|
||||||
|
if ( api.has( syncedSettingId ) && ! events['settings-modified-while-loading'][ syncedSettingId ] ) {
|
||||||
|
delete events.settings[ syncedSettingId ];
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
$.each( events, function( event, args ) {
|
$.each( events, function( event, args ) {
|
||||||
api.preview.trigger( event, args );
|
api.preview.trigger( event, args );
|
||||||
});
|
});
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.7-beta1-39111';
|
$wp_version = '4.7-beta1-39112';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
|
Loading…
Reference in New Issue