diff options
Diffstat (limited to 'core/modules/comment/js')
4 files changed, 23 insertions, 19 deletions
diff --git a/core/modules/comment/js/comment-new-indicator.es6.js b/core/modules/comment/js/comment-new-indicator.es6.js index ffd9efed5ef6..485af485276a 100644 --- a/core/modules/comment/js/comment-new-indicator.es6.js +++ b/core/modules/comment/js/comment-new-indicator.es6.js @@ -30,9 +30,9 @@ if (timestamp > lastViewTimestamp) { // Turn the placeholder into an actual "new" indicator. - const $comment = $(placeholder) + placeholder.textContent = newCommentString; + $placeholder .removeClass('hidden') - .text(newCommentString) .closest('.js-comment') // Add 'new' class to the comment, so it can be styled. .addClass('new'); @@ -41,13 +41,13 @@ // this is the first new comment in the DOM. if (isFirstNewComment) { isFirstNewComment = false; - $comment.prev().before('<a id="new"></a>'); + $placeholder.prev().before('<a id="new"></a>'); // If the URL points to the first new comment, then scroll to that // comment. if (window.location.hash === '#new') { window.scrollTo( 0, - $comment.offset().top - Drupal.displace.offsets.top, + $placeholder.offset().top - Drupal.displace.offsets.top, ); } } diff --git a/core/modules/comment/js/comment-new-indicator.js b/core/modules/comment/js/comment-new-indicator.js index 64416bd63a0a..63c6ee24558b 100644 --- a/core/modules/comment/js/comment-new-indicator.js +++ b/core/modules/comment/js/comment-new-indicator.js @@ -18,14 +18,15 @@ const lastViewTimestamp = Drupal.history.getLastRead(nodeID); if (timestamp > lastViewTimestamp) { - const $comment = $(placeholder).removeClass('hidden').text(newCommentString).closest('.js-comment').addClass('new'); + placeholder.textContent = newCommentString; + $placeholder.removeClass('hidden').closest('.js-comment').addClass('new'); if (isFirstNewComment) { isFirstNewComment = false; - $comment.prev().before('<a id="new"></a>'); + $placeholder.prev().before('<a id="new"></a>'); if (window.location.hash === '#new') { - window.scrollTo(0, $comment.offset().top - Drupal.displace.offsets.top); + window.scrollTo(0, $placeholder.offset().top - Drupal.displace.offsets.top); } } } diff --git a/core/modules/comment/js/node-new-comments-link.es6.js b/core/modules/comment/js/node-new-comments-link.es6.js index add49dd29462..074864b4a8ef 100644 --- a/core/modules/comment/js/node-new-comments-link.es6.js +++ b/core/modules/comment/js/node-new-comments-link.es6.js @@ -115,17 +115,17 @@ function render(results) { Object.keys(results || {}).forEach((nodeID) => { if ($placeholdersToUpdate.hasOwnProperty(nodeID)) { - $placeholdersToUpdate[nodeID] - .attr('href', results[nodeID].first_new_comment_link) - .text( - Drupal.formatPlural( - results[nodeID].new_comment_count, - '1 new comment', - '@count new comments', - ), - ) + const $placeholderItem = $placeholdersToUpdate[nodeID]; + const result = results[nodeID]; + $placeholderItem[0].textContent = Drupal.formatPlural( + result.new_comment_count, + '1 new comment', + '@count new comments', + ); + $placeholderItem + .attr('href', result.first_new_comment_link) .removeClass('hidden'); - show($placeholdersToUpdate[nodeID]); + show($placeholderItem); } }); } diff --git a/core/modules/comment/js/node-new-comments-link.js b/core/modules/comment/js/node-new-comments-link.js index ebac99a578f7..6577421f21d6 100644 --- a/core/modules/comment/js/node-new-comments-link.js +++ b/core/modules/comment/js/node-new-comments-link.js @@ -44,8 +44,11 @@ function render(results) { Object.keys(results || {}).forEach(nodeID => { if ($placeholdersToUpdate.hasOwnProperty(nodeID)) { - $placeholdersToUpdate[nodeID].attr('href', results[nodeID].first_new_comment_link).text(Drupal.formatPlural(results[nodeID].new_comment_count, '1 new comment', '@count new comments')).removeClass('hidden'); - show($placeholdersToUpdate[nodeID]); + const $placeholderItem = $placeholdersToUpdate[nodeID]; + const result = results[nodeID]; + $placeholderItem[0].textContent = Drupal.formatPlural(result.new_comment_count, '1 new comment', '@count new comments'); + $placeholderItem.attr('href', result.first_new_comment_link).removeClass('hidden'); + show($placeholderItem); } }); } |