diff --git a/src/js/_enqueues/lib/comment-reply.js b/src/js/_enqueues/lib/comment-reply.js index d86403bbeb..698e894304 100644 --- a/src/js/_enqueues/lib/comment-reply.js +++ b/src/js/_enqueues/lib/comment-reply.js @@ -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.