From ff8708bb8edcaac701812e5e6969e2c440c08d50 Mon Sep 17 00:00:00 2001
From: Mark Carver <mark.carver@me.com>
Date: Sat, 20 Jan 2018 15:13:14 -0600
Subject: [PATCH] Issue #2892936 by markcarver, i.bajrai, alexeiseremet: too
 many classes in status-messages.html.twig

Signed-off-by: Mark Carver <mark.carver@me.com>
---
 templates/system/status-messages.html.twig | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/templates/system/status-messages.html.twig b/templates/system/status-messages.html.twig
index 0920b96..9881a2c 100644
--- a/templates/system/status-messages.html.twig
+++ b/templates/system/status-messages.html.twig
@@ -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,
@@ -43,13 +46,14 @@
 %}
 {% for type, messages in message_list %}
 {%
-  set classes = [
+  set message_classes = [
     'alert',
     'alert-' ~ status_classes[type],
     'alert-dismissible',
   ]
 %}
-<div{{ attributes.addClass(classes) }} role="alert">
+{# 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>
-- 
2.15.1

