From 2f5aa850653d7139a320bc34ba08dae6c8fe3dae Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 18 Oct 2020 06:41:04 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@49187 git-svn-id: http://core.svn.wordpress.org/trunk@48949 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/comment-reply.js | 10 ++++++++++ wp-includes/js/comment-reply.min.js | 2 +- wp-includes/version.php | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/wp-includes/js/comment-reply.js b/wp-includes/js/comment-reply.js index 9e4b77d31d..5d20672058 100644 --- a/wp-includes/js/comment-reply.js +++ b/wp-includes/js/comment-reply.js @@ -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; } diff --git a/wp-includes/js/comment-reply.min.js b/wp-includes/js/comment-reply.min.js index 8c5475821c..cb4c954e2c 100644 --- a/wp-includes/js/comment-reply.min.js +++ b/wp-includes/js/comment-reply.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -window.addComment=function(p){var f,v,I,C=p.document,h={commentReplyClass:"comment-reply-link",commentReplyTitleId:"reply-title",cancelReplyId:"cancel-comment-reply-link",commentFormId:"commentform",temporaryFormId:"wp-temp-form-div",parentIdFieldId:"comment_parent",postIdFieldId:"comment_post_ID"},e=p.MutationObserver||p.WebKitMutationObserver||p.MozMutationObserver,i="querySelector"in C&&"addEventListener"in p,n=!!C.documentElement.dataset;function t(){r(),function(){if(!e)return;new e(o).observe(C.body,{childList:!0,subtree:!0})}()}function r(e){if(i&&(f=E(h.cancelReplyId),v=E(h.commentFormId),f)){f.addEventListener("touchstart",l),f.addEventListener("click",l);var t=function(e){if((e.metaKey||e.ctrlKey)&&13===e.keyCode)return v.removeEventListener("keydown",t),e.preventDefault(),v.submit.click(),!1};v&&v.addEventListener("keydown",t);for(var n,r=function(e){var t,n=h.commentReplyClass;e&&e.childNodes||(e=C);t=C.getElementsByClassName?e.getElementsByClassName(n):e.querySelectorAll("."+n);return t}(e),o=0,d=r.length;o