Skip to content

Commit c1095a7

Browse files
committed
Heartbeat: Handle race condition in wp-auth-check where heartbeat-tick may fire before DOMContentLoaded.
Developed in WordPress/wordpress-develop#10624 Follow-up to [23805], [50547]. Props westonruter, ArtZ91, siliconforks. See #23295. Fixes #64403. Built from https://develop.svn.wordpress.org/trunk@61379 git-svn-id: http://core.svn.wordpress.org/trunk@60691 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent f7c6119 commit c1095a7

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

wp-includes/js/wp-auth-check.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,23 @@
159159
setShowTimeout();
160160
});
161161
}).on( 'heartbeat-tick.wp-auth-check', function( e, data ) {
162-
if ( 'wp-auth-check' in data ) {
162+
if ( ! ( 'wp-auth-check' in data ) ) {
163+
return;
164+
}
165+
166+
var showOrHide = function () {
163167
if ( ! data['wp-auth-check'] && wrap.hasClass( 'hidden' ) && ! tempHidden ) {
164168
show();
165169
} else if ( data['wp-auth-check'] && ! wrap.hasClass( 'hidden' ) ) {
166170
hide();
167171
}
172+
};
173+
174+
// This is necessary due to a race condition where the heartbeat-tick event may fire before DOMContentLoaded.
175+
if ( wrap ) {
176+
showOrHide();
177+
} else {
178+
$( showOrHide );
168179
}
169180
});
170181

wp-includes/js/wp-auth-check.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '7.0-alpha-61377';
19+
$wp_version = '7.0-alpha-61379';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)