1/** 2 * @file 3 * Message template overrides. 4 */ 5 6((Drupal) => { 7 /** 8 * Overrides message theme function. 9 * 10 * @param {object} message 11 * The message object. 12 * @param {string} message.text 13 * The message text. 14 * @param {object} options 15 * The message context. 16 * @param {string} options.type 17 * The message type. 18 * @param {string} options.id 19 * ID of the message, for reference. 20 * 21 * @return {HTMLElement} 22 * A DOM Node. 23 */ 24 Drupal.theme.message = ({ text }, { type, id }) => { 25 const messagesTypes = Drupal.Message.getMessageTypeLabels(); 26 const messageWrapper = document.createElement('div'); 27 28 messageWrapper.setAttribute( 29 'class', 30 `messages messages--${type} messages-list__item`, 31 ); 32 messageWrapper.setAttribute( 33 'role', 34 type === 'error' || type === 'warning' ? 'alert' : 'status', 35 ); 36 messageWrapper.setAttribute('aria-labelledby', `${id}-title`); 37 messageWrapper.setAttribute('data-drupal-message-id', id); 38 messageWrapper.setAttribute('data-drupal-message-type', type); 39 40 messageWrapper.innerHTML = ` 41 <div class="messages__header"> 42 <h2 id="${id}-title" class="messages__title"> 43 ${messagesTypes[type]} 44 </h2> 45 </div> 46 <div class="messages__content"> 47 ${text} 48 </div> 49 `; 50 51 return messageWrapper; 52 }; 53})(Drupal);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.