core/includes/theme.inc | 6 ++--- .../Drupal/system/Controller/SystemController.php | 24 +++++++++++++------- .../Drupal/system/Tests/Batch/ProcessingTest.php | 12 +++++----- .../Tests/System/DefaultMobileMetaTagsTest.php | 6 ++--- .../modules/batch_test/batch_test.callbacks.inc | 2 +- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/core/includes/theme.inc b/core/includes/theme.inc index b26c75a..cc2f1de 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1305,8 +1305,7 @@ function theme_links($variables) { } // Add a "data-drupal-link-query" attribute to let the - // drupal.active-link library know the query in a standardized - // manner. + // drupal.active-link library know the query in a standardized manner. if (!empty($link['query'])) { $query = $link['query']; ksort($query); @@ -1321,8 +1320,7 @@ function theme_links($variables) { } // Add a "data-drupal-link-system-path" attribute to let the - // drupal.active-link library know the path in a standardized - // manner. + // drupal.active-link library know the path in a standardized manner. $li_attributes['data-drupal-link-system-path'] = \Drupal::service('path.alias_manager.cached')->getSystemPath($path); } diff --git a/core/modules/system/lib/Drupal/system/Controller/SystemController.php b/core/modules/system/lib/Drupal/system/Controller/SystemController.php index d25554dc..259ef66 100644 --- a/core/modules/system/lib/Drupal/system/Controller/SystemController.php +++ b/core/modules/system/lib/Drupal/system/Controller/SystemController.php @@ -184,7 +184,7 @@ public function themeSetDefault() { */ public static function setLinkActiveClass(array $element, array $context) { // Ensure we only manipulate HTML markup. - if (substr($element['#markup'], 0, 9) !== '"'; + $query .= " or @data-drupal-link-system-path=''"; } // The language of an active link is equal to the current language. if ($context['language']) { - $query .= ' and (not(@hreflang) or @hreflang="' . $context['language'] . '")'; + $query .= " and (not(@hreflang) or @hreflang='" . $context['language'] . "')"; } // The query parameters of an active link are equal to the current // parameters. if ($context['query']) { - $query .= ' and @data-drupal-link-query="' . Json::encode($context['query']) . '"'; + $query .= " and @data-drupal-link-query='" . Json::encode($context['query']) . "'"; } - $query .= ']'; + else { + $query .= " and not(@data-drupal-link-query)"; + } + $query .= "]"; // Set the "active" class on all matching HTML elements. $dom = new \DOMDocument(); @$dom->loadHTML($element['#markup']); $xpath = new \DOMXPath($dom); foreach ($xpath->query($query) as $node) { - $node->setAttribute('class', $node->getAttribute('class') . ' active'); + $class = $node->getAttribute('class'); + if (strlen($class) > 0) { + $class .= ' '; + } + $class .= 'active'; + $node->setAttribute('class', $class); } $element['#markup'] = $dom->saveHTML(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php b/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php index de63b73..f6c4644 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Batch/ProcessingTest.php @@ -250,28 +250,28 @@ function _resultMessages($id) { switch ($id) { case 'batch_0': - $messages[] = 'results for batch 0
none'; + $messages[] = 'results for batch 0
none'; break; case 'batch_1': - $messages[] = 'results for batch 1
op 1: processed 10 elements'; + $messages[] = 'results for batch 1
op 1: processed 10 elements'; break; case 'batch_2': - $messages[] = 'results for batch 2
op 2: processed 10 elements'; + $messages[] = 'results for batch 2
op 2: processed 10 elements'; break; case 'batch_3': - $messages[] = 'results for batch 3
op 1: processed 10 elements
op 2: processed 10 elements'; + $messages[] = 'results for batch 3
op 1: processed 10 elements
op 2: processed 10 elements'; break; case 'batch_4': - $messages[] = 'results for batch 4
op 1: processed 10 elements'; + $messages[] = 'results for batch 4
op 1: processed 10 elements'; $messages = array_merge($messages, $this->_resultMessages('batch_2')); break; case 'batch_5': - $messages[] = 'results for batch 5
op 1: processed 10 elements. $context[\'finished\'] > 1 returned from batch process, with success.'; + $messages[] = 'results for batch 5
op 1: processed 10 elements. $context[\'finished\'] > 1 returned from batch process, with success.'; break; case 'chained': diff --git a/core/modules/system/lib/Drupal/system/Tests/System/DefaultMobileMetaTagsTest.php b/core/modules/system/lib/Drupal/system/Tests/System/DefaultMobileMetaTagsTest.php index ba0889f..aaaf2bd 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/DefaultMobileMetaTagsTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/DefaultMobileMetaTagsTest.php @@ -22,9 +22,9 @@ public static function getInfo() { function setUp() { parent::setUp(); $this->default_metatags = array( - 'MobileOptimized' => '', - 'HandheldFriendly' => '', - 'viewport' => '', + 'MobileOptimized' => ' ' '@args', array('@op' => $error_operation[0], '@args' => print_r($error_operation[1], TRUE))); } - drupal_set_message(implode('
', $messages)); + drupal_set_message(implode('
', $messages)); } /**