diff --git a/core/modules/system/src/Controller/SystemController.php b/core/modules/system/src/Controller/SystemController.php index cce4706..9ed4227 100644 --- a/core/modules/system/src/Controller/SystemController.php +++ b/core/modules/system/src/Controller/SystemController.php @@ -398,33 +398,33 @@ public static function setLinkActiveClass(array $element, array $context) { $node = $dom->getElementsByTagName('body')->item(0)->firstChild; // Ensure we don't set the "active" class twice on the same element. - $is_active = !in_array('active', explode(' ', $node->getAttribute('class'))); + $class = $node->getAttribute('class'); + $add_active = !in_array('active', explode(' ', $class)); // The language of an active link is equal to the current language. - if ($is_active && $context['language']) { + if ($add_active && $context['language']) { if ($node->hasAttribute('hreflang') && $node->getAttribute('hreflang') !== $context['language']) { - $is_active = FALSE; + $add_active = FALSE; } } // The query parameters of an active link are equal to the current // parameters. - if ($is_active) { + if ($add_active) { if ($context['query']) { if (!$node->hasAttribute('data-drupal-link-query') || $node->getAttribute('data-drupal-link-query') !== Json::encode($context['query'])) { - $is_active = FALSE; + $add_active = FALSE; } } else { if ($node->hasAttribute('data-drupal-link-query')) { - $is_active = FALSE; + $add_active = FALSE; } } } // Only if the the path, the language and the query match, we set the // "active" class. - if ($is_active) { - $class = $node->getAttribute('class'); + if ($add_active) { if (strlen($class) > 0) { $class .= ' '; }