Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / comment / js / comment-by-viewer.es6.js
1 /**
2  * @file
3  * Attaches behaviors for the Comment module's "by-viewer" class.
4  */
5
6 (function ($, Drupal, drupalSettings) {
7   /**
8    * Add 'by-viewer' class to comments written by the current user.
9    *
10    * @type {Drupal~behavior}
11    */
12   Drupal.behaviors.commentByViewer = {
13     attach(context) {
14       const currentUserID = parseInt(drupalSettings.user.uid, 10);
15       $('[data-comment-user-id]')
16         .filter(function () {
17           return parseInt(this.getAttribute('data-comment-user-id'), 10) === currentUserID;
18         })
19         .addClass('by-viewer');
20     },
21   };
22 }(jQuery, Drupal, drupalSettings));