Editor: Correct the check for unsaved content in wp.autosave.server.postChanged().

This fixes improper triggering of the "Are you sure?" prompt when navigating away from the old, "classic" Edit Post screen and there are no changes.

The previous check did not account for Pages or any custom post types that don't have a Title, Content, or Excerpt field.

Follow-up to [50031].

Props hwk-fr, mukesh27, audrasjb, archon810, Clorith, ibiza69, tonysandwich, roger995, bartosz777, viablethought, dbtedg, worldedu, hmabpera, magnuswebdesign.
Merges [50232] to the 5.6 branch.
Fixes #52440.
Built from https://develop.svn.wordpress.org/branches/5.6@50366


git-svn-id: http://core.svn.wordpress.org/branches/5.6@49977 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
desrosj 2021-02-16 20:23:59 +00:00
parent 6ae20f561e
commit 757e0dc15b
3 changed files with 4 additions and 4 deletions

View File

@ -710,7 +710,7 @@ window.autosave = function() {
var editor = window.tinymce.get( field );
if ( ! editor || editor.isHidden() ) {
if ( $( '#' + field ).val() !== initialCompareData[ field ] ) {
if ( ( $( '#' + field ).val() || '' ) !== initialCompareData[ field ] ) {
changed = true;
// Break.
return false;
@ -721,7 +721,7 @@ window.autosave = function() {
}
} );
if ( $( '#title' ).val() !== initialCompareData.post_title ) {
if ( ( $( '#title' ).val() || '' ) !== initialCompareData.post_title ) {
changed = true;
}

File diff suppressed because one or more lines are too long

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.6.2-alpha-50356';
$wp_version = '5.6.2-alpha-50366';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.