WordPress.org

Make WordPress Core

Ticket #46280: 46280.3.diff

File 46280.3.diff, 1.8 KB (added by peterwilsoncc, 19 months ago)
  • src/js/_enqueues/lib/comment-reply.js

    diff --git a/src/js/_enqueues/lib/comment-reply.js b/src/js/_enqueues/lib/comment-reply.js
    index fae92ee237..9b06715253 100644
    a b window.addComment = ( function( window ) { 
    3232         * Check browser supports dataset.
    3333         * !! sets the variable to true if the property exists.
    3434         */
    35         var supportsDataset = !! document.body.dataset;
     35        var supportsDataset = !! document.documentElement.dataset;
    3636
    3737        // For holding the cancel element.
    3838        var cancelElement;
    window.addComment = ( function( window ) { 
    4646        // The mutation observer.
    4747        var observer;
    4848
    49         // Initialise the events.
    50         init();
     49        if ( cutsTheMustard && document.readyState !== 'loading' ) {
     50                ready();
     51        } else if ( cutsTheMustard ) {
     52                window.addEventListener( 'DOMContentLoaded', ready, false );
     53        }
     54
     55        /**
     56         * Sets up object variables after the DOM is ready.
     57         *
     58         * @since 5.1.0
     59         */
     60        function ready() {
     61                // Initialise the events.
     62                init();
    5163
    52         // Set up a MutationObserver to check for comments loaded late.
    53         observeChanges();
     64                // Set up a MutationObserver to check for comments loaded late.
     65                observeChanges();
     66        }
    5467
    5568        /**
    5669         * Add events to links classed .comment-reply-link.
    window.addComment = ( function( window ) { 
    163176                        postId    = getDataAttribute( replyLink, 'postid'),
    164177                        follow;
    165178
     179                if ( ! commId || ! parentId || ! respondId || ! postId ) {
     180                        /*
     181                         * Theme or plugin defines own link via custom `wp_list_comments()` callback
     182                         * and calls `moveForm()` either directly or via a custom event hook.
     183                         */
     184                        return;
     185                }
     186
    166187                /*
    167188                 * Third party comments systems can hook into this function via the global scope,
    168189                 * therefore the click event needs to reference the global scope.