Make WordPress Core

Ticket #46280: 46280.2.diff

File 46280.2.diff, 1.8 KB (added by peterwilsoncc, 4 years 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..28d190d86a 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 ( document.readyState !== 'loading' ) {
     50                ready();
     51        } else if ( cutsTheMustard ) {
     52                window.addEventListener( 'DOMContentLoaded', ready, false );
     53        }
    5154
    52         // Set up a MutationObserver to check for comments loaded late.
    53         observeChanges();
     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();
     63
     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
     180                if ( ! commId || ! parentId || ! respondId || ! postId ) {
     181                        /*
     182                         * Theme or plugin defines own link via custom `wp_list_comments()` callback
     183                         * and calls `moveForm()` either directly or via a custom event hook.
     184                         */
     185                        return;
     186                }
     187
    166188                /*
    167189                 * Third party comments systems can hook into this function via the global scope,
    168190                 * therefore the click event needs to reference the global scope.