diff --git a/core/lib/Drupal/Core/Menu/MenuLinkTree.php b/core/lib/Drupal/Core/Menu/MenuLinkTree.php index 090293c..fa27f54 100644 --- a/core/lib/Drupal/Core/Menu/MenuLinkTree.php +++ b/core/lib/Drupal/Core/Menu/MenuLinkTree.php @@ -243,26 +243,24 @@ protected function buildItems(array $tree, CacheableMetadata &$tree_access_cache if ($data->access instanceof AccessResultInterface && !$data->access->isAllowed()) { continue; } + $element = array(); - $class = ['menu-item']; - // Set a class for the
  • -tag. Only set 'expanded' class if the link + // Set a variable for the
  • -tag. Only set 'expanded' true if the link // also has visible children within the current tree. if ($data->hasChildren && !empty($data->subtree)) { - $class[] = 'menu-item--expanded'; + $element['is_expanded'] = TRUE; } elseif ($data->hasChildren) { - $class[] = 'menu-item--collapsed'; + $element['is_collapsed'] = TRUE; } // Set a class if the link is in the active trail. if ($data->inActiveTrail) { - $class[] = 'menu-item--active-trail'; + $element['is_active_trail'] = TRUE; } // Note: links are rendered in the menu.html.twig template; and they // automatically bubble their associated cacheability metadata. - $element = array(); $element['attributes'] = new Attribute(); - $element['attributes']['class'] = $class; $element['title'] = $link->getTitle(); $element['url'] = $link->getUrlObject(); $element['url']->setOption('set_active_class', TRUE); diff --git a/core/modules/toolbar/templates/menu--toolbar.html.twig b/core/modules/toolbar/templates/menu--toolbar.html.twig index 3578b95..090b7a4 100644 --- a/core/modules/toolbar/templates/menu--toolbar.html.twig +++ b/core/modules/toolbar/templates/menu--toolbar.html.twig @@ -32,7 +32,15 @@