Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / comment / js / node-new-comments-link.es6.js
index 9f1588fd99acb36f8c3d48f696d1c6600cec731b..a2bdc35b9d7272b4950f55f303a27b73eacf0486 100644 (file)
       // Find the parent <li>.
       .closest('.comment-new-comments')
       // Find the preceding <li>, if any, and give it the 'last' class.
-      .prev().addClass('last')
+      .prev()
+      .addClass('last')
       // Go back to the parent <li> and hide it.
-      .end().hide();
+      .end()
+      .hide();
   }
 
   /**
       // Find the parent <li>.
       .closest('.comment-new-comments')
       // Find the preceding <li>, if any, and remove its 'last' class, if any.
-      .prev().removeClass('last')
+      .prev()
+      .removeClass('last')
       // Go back to the parent <li> and show it.
-      .end().show();
+      .end()
+      .show();
   }
 
   /**
      *   Data about new comment links indexed by nodeID.
      */
     function render(results) {
-      for (const nodeID in results) {
-        if (results.hasOwnProperty(nodeID) && $placeholdersToUpdate.hasOwnProperty(nodeID)) {
+      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]);
         }
-      }
+      });
     }
 
     if (drupalSettings.comment && drupalSettings.comment.newCommentsLinks) {