Make WordPress Core

Changeset 61379


Ignore:
Timestamp:
12/14/2025 10:28:52 PM (2 months ago)
Author:
westonruter
Message:

Heartbeat: Handle race condition in wp-auth-check where heartbeat-tick may fire before DOMContentLoaded.

Developed in https://github.com/WordPress/wordpress-develop/pull/10624

Follow-up to [23805], [50547].

Props westonruter, ArtZ91, siliconforks.
See #23295.
Fixes #64403.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/lib/auth-check.js

    r50547 r61379  
    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();
     
    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    });
Note: See TracChangeset for help on using the changeset viewer.