WordPress.org

Make WordPress Core

Changeset 48904


Ignore:
Timestamp:
08/28/2020 01:10:29 PM (3 months ago)
Author:
SergeyBiryukov
Message:

Comments: Check if reply heading text node exists before accessing its property in comment-reply.js.

Follow-up to [47506], [48876].

Props johannadevos, mailnew2ster.
Fixes #38009.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/lib/comment-reply.js

    r48876 r48904  
    176176        temporaryElement.parentNode.replaceChild( respondElement, temporaryElement );
    177177        cancelLink.style.display = 'none';
    178         var replyHeadingElement = getElementById( config.commentReplyTitleId );
     178
     179        var replyHeadingElement  = getElementById( config.commentReplyTitleId );
    179180        var replyHeadingTextNode = replyHeadingElement && replyHeadingElement.firstChild;
     181
    180182        if ( replyHeadingTextNode && replyHeadingTextNode.nodeType === Node.TEXT_NODE && headingText ) {
    181183            replyHeadingTextNode.textContent = headingText;
    182184        }
     185
    183186        event.preventDefault();
    184187    }
     
    315318        var element, cssHidden, style;
    316319
    317         var replyHeading = getElementById( config.commentReplyTitleId );
     320        var replyHeading         = getElementById( config.commentReplyTitleId );
    318321        var replyHeadingTextNode = replyHeading && replyHeading.firstChild;
    319322
     
    338341        cancelElement.style.display = '';
    339342        addBelowElement.parentNode.insertBefore( respondElement, addBelowElement.nextSibling );
    340         if ( replyHeadingTextNode.nodeType === Node.TEXT_NODE ) {
     343
     344        if ( replyHeadingTextNode && replyHeadingTextNode.nodeType === Node.TEXT_NODE ) {
    341345            replyHeadingTextNode.textContent = replyTo;
    342346        }
     347
    343348        /*
    344349         * This is for backward compatibility with third party commenting systems
Note: See TracChangeset for help on using the changeset viewer.