Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / themes / contrib / bootstrap / templates / system / status-messages.html.twig
index 327bfb586a5419b1611f452f41abde32d8098042..2150d50f53fdf1c850cbe5f3fdaecba78fd988c1 100644 (file)
@@ -25,6 +25,9 @@
  * @see template_preprocess_status_messages()
  */
 #}
+{# Save original attribute classes. This is needed to override in loop below. #}
+{# @see https://www.drupal.org/project/bootstrap/issues/2892936 #}
+{% set classes = attributes.offsetGet('class')|default({}) %}
 {%
   set status_heading = {
     'status': 'Status message'|t,
   }
 %}
 {% for type, messages in message_list %}
-{%
-  set classes = [
-    'alert',
-    'alert-' ~ status_classes[type],
-    'alert-dismissible',
-  ]
-%}
-<div{{ attributes.addClass(classes) }} role="alert">
-  <a href="#" role="button" class="close" data-dismiss="alert" aria-label="{{ 'Close'|t }}"><span aria-hidden="true">&times;</span></a>
-  {% if status_headings[type] %}
-    <h4 class="sr-only">{{ status_headings[type] }}</h4>
-  {% endif %}
-  {% if messages|length > 1 %}
-    <ul class="item-list item-list--messages">
-      {% for message in messages %}
-        <li class="item item--message">{{ message }}</li>
-      {% endfor %}
-    </ul>
-  {% else %}
-    {{ messages|first }}
-  {% endif %}
-</div>
+  {%
+    set message_classes = [
+      'alert',
+      'alert-' ~ status_classes[type],
+      'alert-dismissible',
+    ]
+  %}
+  {# Reset the attribute classes and then add the message specific classes. #}
+  <div{{ attributes.setAttribute('class', classes).addClass(message_classes).setAttribute('role', 'alert') }}>
+    <button role="button" class="close" data-dismiss="alert" aria-label="{{ 'Close'|t }}"><span aria-hidden="true">&times;</span></button>
+    {% if status_headings[type] %}
+      <h4 class="sr-only">{{ status_headings[type] }}</h4>
+    {% endif %}
+    {% if messages|length > 1 %}
+      <ul class="item-list item-list--messages">
+        {% for message in messages %}
+          <li class="item item--message">{{ message }}</li>
+        {% endfor %}
+      </ul>
+    {% else %}
+      {{ messages|first }}
+    {% endif %}
+  </div>
 {% endfor %}