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

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

Props johannadevos, mailnew2ster.
Merges [48904] to the 5.5 branch.
Fixes #38009.

git-svn-id: https://develop.svn.wordpress.org/branches/5.5@48917 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers 2020-08-31 18:12:11 +00:00
parent 56fef3742a
commit d5e894c20c
1 changed files with 8 additions and 3 deletions

View File

@ -175,11 +175,14 @@ window.addComment = ( function( window ) {
var headingText = temporaryElement.textContent;
temporaryElement.parentNode.replaceChild( respondElement, temporaryElement );
cancelLink.style.display = 'none';
var replyHeadingElement = getElementById( config.commentReplyTitleId );
var replyHeadingElement = getElementById( config.commentReplyTitleId );
var replyHeadingTextNode = replyHeadingElement && replyHeadingElement.firstChild;
if ( replyHeadingTextNode && replyHeadingTextNode.nodeType === Node.TEXT_NODE && headingText ) {
replyHeadingTextNode.textContent = headingText;
}
event.preventDefault();
}
@ -314,7 +317,7 @@ window.addComment = ( function( window ) {
var postIdField = getElementById( config.postIdFieldId );
var element, cssHidden, style;
var replyHeading = getElementById( config.commentReplyTitleId );
var replyHeading = getElementById( config.commentReplyTitleId );
var replyHeadingTextNode = replyHeading && replyHeading.firstChild;
if ( ! addBelowElement || ! respondElement || ! parentIdField ) {
@ -337,9 +340,11 @@ window.addComment = ( function( window ) {
cancelElement.style.display = '';
addBelowElement.parentNode.insertBefore( respondElement, addBelowElement.nextSibling );
if ( replyHeadingTextNode.nodeType === Node.TEXT_NODE ) {
if ( replyHeadingTextNode && replyHeadingTextNode.nodeType === Node.TEXT_NODE ) {
replyHeadingTextNode.textContent = replyTo;
}
/*
* This is for backward compatibility with third party commenting systems
* hooking into the event using older techniques.