From e85d243d81ed2422348480f6291558eb7bf5cbe0 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 27 Aug 2020 01:59:09 +0000 Subject: [PATCH] Comments: Correct the check for reply element existence in `comment-reply.js`. `document.getElementById()` returns `null` if no matching element was found, so the previous comparison didn't work as expected. Follow-up to [47506]. Props mailnew2ster, sarahricker. Fixes #38009. Built from https://develop.svn.wordpress.org/trunk@48876 git-svn-id: http://core.svn.wordpress.org/trunk@48638 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/comment-reply.js | 2 +- wp-includes/js/comment-reply.min.js | 2 +- wp-includes/version.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-includes/js/comment-reply.js b/wp-includes/js/comment-reply.js index 1f111230c9..d86403bbeb 100644 --- a/wp-includes/js/comment-reply.js +++ b/wp-includes/js/comment-reply.js @@ -408,7 +408,7 @@ window.addComment = ( function( window ) { var temporaryFormId = config.temporaryFormId; var temporaryElement = getElementById( temporaryFormId ); var replyElement = getElementById( config.commentReplyTitleId ); - var initialHeadingText = ( 'undefined' !== typeof replyElement ) ? replyElement.firstChild.textContent : ''; + var initialHeadingText = replyElement ? replyElement.firstChild.textContent : ''; if ( temporaryElement ) { // The element already exists, no need to recreate. diff --git a/wp-includes/js/comment-reply.min.js b/wp-includes/js/comment-reply.min.js index c0f221d939..f16a38475f 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