Issue #2968541 by vokidas, borisson_: ActiveLinkResponseFilter fails to set active link with query in non-alphabetical order
parent
4ed1bcf646
commit
ef8a5c3de6
|
@ -127,6 +127,9 @@ class ActiveLinkResponseFilter implements EventSubscriberInterface {
|
|||
$search_key_current_path = 'data-drupal-link-system-path="' . $current_path . '"';
|
||||
$search_key_front = 'data-drupal-link-system-path="<front>"';
|
||||
|
||||
// Receive the query in a standardized manner.
|
||||
ksort($query);
|
||||
|
||||
$offset = 0;
|
||||
// There are two distinct conditions that can make a link be marked active:
|
||||
// 1. A link has the current path in its 'data-drupal-link-system-path'
|
||||
|
|
|
@ -238,6 +238,19 @@ class ActiveLinkResponseFilterTest extends UnitTestCase {
|
|||
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => ""]];
|
||||
$situations[] = ['context' => $context, 'is active' => FALSE, 'attributes' => $attributes + ['hreflang' => 'en', 'data-drupal-link-query' => TRUE]];
|
||||
|
||||
// Query with unsorted keys must match when the attribute is in sorted form.
|
||||
$context = [
|
||||
'path' => 'myfrontpage',
|
||||
'front' => TRUE,
|
||||
'language' => 'en',
|
||||
'query' => ['foo' => 'bar', 'baz' => 'qux'],
|
||||
];
|
||||
$attributes = [
|
||||
'data-drupal-link-system-path' => 'myfrontpage',
|
||||
'data-drupal-link-query' => Json::encode(['baz' => 'qux', 'foo' => 'bar']),
|
||||
];
|
||||
$situations[] = ['context' => $context, 'is active' => TRUE, 'attributes' => $attributes];
|
||||
|
||||
// Loop over the surrounding HTML variations.
|
||||
$data = [];
|
||||
for ($h = 0; $h < count($html); $h++) {
|
||||
|
|
Loading…
Reference in New Issue