diff --git a/core/lib/Drupal/Core/Menu/MenuLinkTree.php b/core/lib/Drupal/Core/Menu/MenuLinkTree.php index a5ea3d2..2070b50 100644 --- a/core/lib/Drupal/Core/Menu/MenuLinkTree.php +++ b/core/lib/Drupal/Core/Menu/MenuLinkTree.php @@ -243,10 +243,12 @@ protected function buildItems(array $tree, CacheableMetadata &$tree_access_cache if ($data->access instanceof AccessResultInterface && !$data->access->isAllowed()) { continue; } - $element = array(); + $element = []; // Set a variable for the
  • -tag. Only set 'expanded' true if the link // also has visible children within the current tree. + $element['is_expanded'] = FALSE; + $element['is_collapsed'] = FALSE; if ($data->hasChildren && !empty($data->subtree)) { $element['is_expanded'] = TRUE; } @@ -254,6 +256,7 @@ protected function buildItems(array $tree, CacheableMetadata &$tree_access_cache $element['is_collapsed'] = TRUE; } // Set a helper variable to indicate whether link is in active trail. + $element['in_active_trail'] = FALSE; if ($data->inActiveTrail) { $element['in_active_trail'] = TRUE; } diff --git a/core/modules/book/src/BookManager.php b/core/modules/book/src/BookManager.php index 556350f..1db319c 100644 --- a/core/modules/book/src/BookManager.php +++ b/core/modules/book/src/BookManager.php @@ -548,6 +548,8 @@ protected function buildItems(array $tree) { // Set a class for the
  • -tag. Since $data['below'] may contain local // tasks, only set 'expanded' true if the link also has children within // the current book. + $element['is_expanded'] = FALSE; + $element['is_collapsed'] = FALSE; if ($data['link']['has_children'] && $data['below']) { $element['is_expanded'] = TRUE; } @@ -556,6 +558,7 @@ protected function buildItems(array $tree) { } // Set a helper variable to indicate whether link is in active trail. + $element['in_active_trail'] = FALSE; if ($data['link']['in_active_trail']) { $element['in_active_trail'] = TRUE; } diff --git a/core/modules/system/tests/src/Unit/Menu/MenuLinkTreeTest.php b/core/modules/system/tests/src/Unit/Menu/MenuLinkTreeTest.php index 64d14b9..52bcce4 100644 --- a/core/modules/system/tests/src/Unit/Menu/MenuLinkTreeTest.php +++ b/core/modules/system/tests/src/Unit/Menu/MenuLinkTreeTest.php @@ -140,7 +140,7 @@ public function providerTestBuildCacheability() { ] ]; - $get_built_element = function(MenuLinkTreeElement $element, array $classes) { + $get_built_element = function(MenuLinkTreeElement $element) { $return = [ 'attributes' => new Attribute(), 'title' => $element->link->getTitle(),