Comments: Hide the link to the initial parent comment in the reply heading when replying to another comment.

This ensures that the reply heading is updated correctly on single post URLs with the `?replytocom` query argument.

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

Props mailnew2ster, wpamitkumar, audrasjb, desrosj, SergeyBiryukov.
Fixes #51175.

git-svn-id: https://develop.svn.wordpress.org/trunk@49187 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-10-18 06:39:21 +00:00
parent 918bebfe3c
commit 7164e4b4c8

View File

@ -178,8 +178,13 @@ window.addComment = ( function( window ) {
var replyHeadingElement = getElementById( config.commentReplyTitleId );
var replyHeadingTextNode = replyHeadingElement && replyHeadingElement.firstChild;
var replyLinkToParent = replyHeadingTextNode && replyHeadingTextNode.nextSibling;
if ( replyHeadingTextNode && replyHeadingTextNode.nodeType === Node.TEXT_NODE && headingText ) {
if ( replyLinkToParent && 'A' === replyLinkToParent.nodeName && replyLinkToParent.id !== config.cancelReplyId ) {
replyLinkToParent.style.display = '';
}
replyHeadingTextNode.textContent = headingText;
}
@ -319,6 +324,7 @@ window.addComment = ( function( window ) {
var replyHeading = getElementById( config.commentReplyTitleId );
var replyHeadingTextNode = replyHeading && replyHeading.firstChild;
var replyLinkToParent = replyHeadingTextNode && replyHeadingTextNode.nextSibling;
if ( ! addBelowElement || ! respondElement || ! parentIdField ) {
// Missing key elements, fail.
@ -342,6 +348,10 @@ window.addComment = ( function( window ) {
addBelowElement.parentNode.insertBefore( respondElement, addBelowElement.nextSibling );
if ( replyHeadingTextNode && replyHeadingTextNode.nodeType === Node.TEXT_NODE ) {
if ( replyLinkToParent && 'A' === replyLinkToParent.nodeName && replyLinkToParent.id !== config.cancelReplyId ) {
replyLinkToParent.style.display = 'none';
}
replyHeadingTextNode.textContent = replyTo;
}