diff --git a/core/includes/menu.inc b/core/includes/menu.inc
index 5aaec8c..0848940 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -37,7 +37,7 @@ function template_preprocess_menu_local_task(&$variables) {
   if (!empty($variables['element']['#active'])) {
     // Add text to indicate active tab for non-visual users.
     $active = '<span class="visually-hidden">' . t('(active tab)') . '</span>';
-    $variables['attributes']['class'] = array('active');
+    $variables['active'] = true;
 
     // If the link does not contain HTML already, String::checkPlain() it now.
     // After we set 'html'=TRUE the link will not be sanitized by l().
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 0bc0584..f3eaca3 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -1193,7 +1193,6 @@ function template_preprocess_file_managed_file(&$variables) {
   if (!empty($element['#attributes']['class'])) {
     $variables['attributes']['class'] = (array) $element['#attributes']['class'];
   }
-  $variables['attributes']['class'][] = 'form-managed-file';
 }
 
 /**
diff --git a/core/themes/classy/templates/file/file-managed-file.html.twig b/core/themes/classy/templates/file/file-managed-file.html.twig
index 9a33ae1..7a87511 100644
--- a/core/themes/classy/templates/file/file-managed-file.html.twig
+++ b/core/themes/classy/templates/file/file-managed-file.html.twig
@@ -12,6 +12,6 @@
  * @ingroup themeable
  */
 #}
-<div{{ attributes }}>
+<div{{ attributes.addClass('form-managed-file') }}>
   {{ element }}
 </div>
diff --git a/core/themes/classy/templates/system/menu-local-task.html.twig b/core/themes/classy/templates/system/menu-local-task.html.twig
index 5939203..8869312 100644
--- a/core/themes/classy/templates/system/menu-local-task.html.twig
+++ b/core/themes/classy/templates/system/menu-local-task.html.twig
@@ -5,6 +5,7 @@
  *
  * Available variables:
  * - attributes: HTML attributes for the wrapper element.
+ * - active: Whether the task item is an active tab.
  * - link: A rendered link element.
  *
  * Note: This template renders the content for each task item in
@@ -15,4 +16,4 @@
  * @ingroup themeable
  */
 #}
-<li{{ attributes }}>{{ link }}</li>
+<li{{ attributes.addClass(active ? 'active') }}>{{ link }}</li>
