Problem/Motivation

The language switcher, specifically the links template uses hreflang on <li>, that is not valid.

Line 57, Column 105: Attribute hreflang not allowed on element li at this point.
<li hreflang="es" data-drupal-link-system-path ...

Steps to reproduce

On a multiingual site with language switcher (e.g. demo_umami), verify with http://validator.w3.org/check

Proposed resolution

Use a data-drupal-language attribute instead. Server and JS processing of of active links needs to be adjusted.

Note: Tests need fairly extensive adjustments because of massive amounts of unit test variations that are being tested.

Remaining tasks

Review

User interface changes

NA

Introduced terminology

NA

API changes

I don't think it qualifies, but in case any custom code would have relied on the hreflang attribute on these elements, that would no longer work.

Data model changes

NA

Release notes snippet

NA

CommentFileSizeAuthor
#138 2454289-138.patch27.47 KBcasey
#132 2454289-attribute-hreflang-not-10.4.x.patch6.34 KBbakop
#130 2454289-nr-bot.txt91 bytesneeds-review-queue-bot
#128 Screenshot 2025-03-18 at 1.41.18 PM.png19.1 KBsmustgrave
#128 Screenshot 2025-03-18 at 1.41.10 PM.png27.06 KBsmustgrave
#122 2454289-122-11.x.patch20.01 KBjonnyhocks
#122 2454289-122-10.3.x.patch20.01 KBjonnyhocks
#118 2454289-118-11.x.patch19.51 KBtimohuisman
#118 2454289-118-10.1.x.patch19.51 KBtimohuisman
#116 2454289-116.patch19.5 KBeugene.brit
#114 D95x_reroll-2454289-114.patch20.5 KBjoseph.olstad
#113 D95x_reroll-2454289-113.patch20.43 KBjoseph.olstad
#109 interdiff_101-109.txt1.92 KBranjith_kumar_k_u
#109 2454289-109.patch22.73 KBranjith_kumar_k_u
#101 D9-2454289-101.patch22.7 KBolivier.br
#99 D9-2454289-99.patch22.82 KBjoseph.olstad
#95 2454289-94.patch22.63 KBalexpott
#95 82-94-interdiff.txt2.45 KBalexpott
#82 2454289-82.patch22.79 KBzviryatko
#82 2454289-80-interdiff.txt866 byteszviryatko
#80 2454289-78.patch22.58 KBzulljin
#77 Screenshot 2019-06-04 at 09.47.33.png152.32 KBmschudders
#75 2454289_75_remove_hreflang_from_li.patch715 bytesmschudders
#72 2454289-63.patch3.29 KBzulljin
#70 2454289-62.patch2.29 KBzulljin
#68 2454289-61.patch3.21 KBzulljin
#60 2454289-60.patch1.95 KBrob holmes
#58 hreflang_attribute_not-2454289-51.patch10.12 KBshamrockonov
#50 interdiff-2454289-45-50.txt778 bytespguillard
#50 hreflang_attribute_not-2454289-50.patch9.37 KBpguillard
#47 hreflang_attribute_not-2454289-45.patch9.38 KBpguillard
#45 hreflang_attribute_not-2454289-45.patch9.38 KBajzetat
#43 hreflang_attribute_not-2454289-43.patch11.74 KBajzetat
#26 interdiff-2454289-24-26.txt4.89 KBpguillard
#26 attribute_hreflang_not-2454289-26.patch9.43 KBpguillard
#24 attribute_hreflang_not-2454289-24.patch4.88 KBpguillard
#16 attribute_hreflang_not-2454289-16.patch7.35 KBAnonymous (not verified)
#16 attribute_hreflang_not-2454289-16.test-only.patch2.31 KBAnonymous (not verified)
#13 attribute_hreflang_not-2454289-12.patch7.41 KBAnonymous (not verified)
#13 attribute_hreflang_not-2454289-12.test-fail.patch2.31 KBAnonymous (not verified)
#8 attribute_hreflang_not-2454289-8.patch7.41 KBAnonymous (not verified)
#8 attribute_hreflang_not-2454289-8.test-fail.patch2.31 KBAnonymous (not verified)
#8 interdiff-6-8.txt2.53 KBAnonymous (not verified)
#6 attribute_hreflang_not-2454289-6.patch4.87 KBAnonymous (not verified)
#6 attribute_hreflang_not-2454289-6.test-fail.patch2.31 KBAnonymous (not verified)
#6 interdiff-5-6.txt2.56 KBAnonymous (not verified)
#5 attribute_hreflang_not-2454289-5.patch2.31 KBAnonymous (not verified)

Issue fork drupal-2454289

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rpayanm’s picture

Issue summary: View changes
rpayanm’s picture

Issue summary: View changes
Anonymous’s picture

I don't think the hreflang attribute makes sense on a list element, since it doesn't link to anything and it hasn't got an href attribute.

I notice the hreflang attribute is rendered on the a tag as well, so could we just remove it on the li tag?

nod_’s picture

li element shouldn't have the data-drupal-link-system-path either. Not sure why we want the li to have the active class. It doesn't happen for menus anywhere else.

Anonymous’s picture

Issue summary: View changes
Status: Active » Needs review
Issue tags: +Needs tests
StatusFileSize
new2.31 KB

Agreed. So let's remove them all.

I'll write some coverage for this issue, but let's already take a look at what fails.

Added a beta eval to the issue summary.

Anonymous’s picture

This already had test coverage, so I fixed the tests.

The last submitted patch, 5: attribute_hreflang_not-2454289-5.patch, failed testing.

Anonymous’s picture

Fixed the remaining test failure.

The last submitted patch, 6: attribute_hreflang_not-2454289-6.test-fail.patch, failed testing.

The last submitted patch, 6: attribute_hreflang_not-2454289-6.patch, failed testing.

rpayanm’s picture

For the record, my base theme is classy.

The last submitted patch, 8: attribute_hreflang_not-2454289-8.test-fail.patch, failed testing.

Anonymous’s picture

The fix removes the attributes in the theme.inc template_preprocess_links() function, and thus is "theme agnostic". I verified this manually.

I did however notice that my patch in #8 wont apply, because I took the diff in a subdirectory. New patches attached, only changing the file paths.

The last submitted patch, 13: attribute_hreflang_not-2454289-12.test-fail.patch, failed testing.

mgifford’s picture

Status: Needs review » Needs work

No longer applies.

Anonymous’s picture

Status: Needs work » Needs review
StatusFileSize
new2.31 KB
new7.35 KB

Html::escape() is now used instead of String::checkPlain(). The conflicts were situated here:

CONFLICT (content): Merge conflict in core/modules/system/src/Tests/Theme/FunctionsTest.php
CONFLICT (content): Merge conflict in core/modules/language/src/Tests/LanguageSwitchingTest.php

Anonymous’s picture

Status: Needs review » Needs work

The test only should have failed. We need to find out why it didn't.

The last submitted patch, 16: attribute_hreflang_not-2454289-16.test-only.patch, failed testing.

Anonymous’s picture

Status: Needs work » Needs review

Strange, these are the fails I would have expected. This seems to be a test bot hick-up.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

laravz’s picture

Not sure whether this helps in any way, but running the patch now leads to the following error (or, at least, it does for me):

Checking patch core/modules/system/src/Tests/Theme/FunctionsTest.php...
error: while searching for:
    $expected_links .= '<li class="a-link"><a href="' . Url::fromUri('base:a/link')->toString() . '">' . Html::escape('A <link>') .                                              '</a></li>';
    $expected_links .= '<li class="plain-text"><span class="a/class">' . Html::escape('Plain "text"') . '</span></li>';
    $expected_links .= '<li class="html-text"><span class="unescaped">' . Html::escape('potentially unsafe text that <should> be es                                             caped') . '</span></li>';
    $expected_links .= '<li data-drupal-link-system-path="&lt;front&gt;" class="front-page"><a href="' . Url::fromRoute('<front>')-                                             >toString() . '" data-drupal-link-system-path="&lt;front&gt;">' . Html::escape('Front page') . '</a></li>';
    $expected_links .= '<li data-drupal-link-system-path="router_test/test1" class="router-test"><a href="' . \Drupal::urlGenerator                                             ()->generate('router_test.1') . '" data-drupal-link-system-path="router_test/test1">' . Html::escape('Test route') . '</a></li>';
    $query = array('key' => 'value');
    $encoded_query = Html::escape(Json::encode($query));
    $expected_links .= '<li data-drupal-link-query="'.$encoded_query.'" data-drupal-link-system-path="router_test/test1" class="que                                             ry-test"><a href="' . \Drupal::urlGenerator()->generate('router_test.1', $query) . '" data-drupal-link-query="'.$encoded_query.'" d                                             ata-drupal-link-system-path="router_test/test1">' . Html::escape('Query test route') . '</a></li>';
    $expected_links .= '</ul>';
    $expected = $expected_heading . $expected_links;
    $this->assertThemeOutput('links', $variables, $expected);

error: patch failed: core/modules/system/src/Tests/Theme/FunctionsTest.php:279
error: core/modules/system/src/Tests/Theme/FunctionsTest.php: patch does not apply
Anonymous’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll, +DevDaysMilan

Well yes, it tells us we need to reroll the patch :)

pguillard’s picture

Assigned: Unassigned » pguillard
pguillard’s picture

Assigned: pguillard » Unassigned
Status: Needs work » Needs review
StatusFileSize
new4.88 KB

Patch rerolled

Status: Needs review » Needs work

The last submitted patch, 24: attribute_hreflang_not-2454289-24.patch, failed testing.

pguillard’s picture

Status: Needs work » Needs review
StatusFileSize
new9.43 KB
new4.89 KB

Changes to pass tests

laravz’s picture

This patch (#26) is working for me. I've no longer got the hreflang attribute within the list element:

<ul class="links"><li class="en"><a href="/en" class="language-link" hreflang="en" data-drupal-link-system-path="&lt;front&gt;">English</a></li></ul>

laravz’s picture

Status: Needs review » Reviewed & tested by the community
pguillard’s picture

Cool, we'll soon be able to check on http://validator.w3.org/check without falling ill :-)

laravz’s picture

I did validate it with https://validator.w3.org/ (Doctype HTML5(experimental)). Not sure whether we would have to check it any further.

alexpott’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: -Needs reroll

So weirdly this is contradicting there own examples see https://www.w3.org/MarkUp/xhtml2/wiki/XHTML2/i18n/hreflang_examples

Are we sure we haven't discovered a bug in the validator?

pguillard’s picture

Hum, you may be right.
But at first, everyone would think "the W3C must be right"

laravz’s picture

Not necessarily, the link describes UL nested in a P, not UL's nested in NAV elements, which is the case in this issue. Though it must be said that W3C also gives an error with the examples presented on the website.

sylus’s picture

The example above is for xhtml not html5. I still think the comment in #2454289-3: Attribute hreflang not allowed on element li at this point holds true as there is no link to anything.

pguillard’s picture

So what do we do now ?

pguillard’s picture

I guess #34 and #3 are right, and it could be also a bug in the validator.
Nonetheless it costs nothing to us to remove this attribute !

laravz’s picture

https://validator.w3.org/nu, another w3c tool, returns the same error as http://validator.w3.org/check. Both state that the HTML5 validator is in an experimental stage, so it wouldn't suprise me if #34 and #3 are correct. However, I can't find any issues on the respective github pages pertaining to this hreflang issue.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

pguillard’s picture

Version: 8.2.x-dev » 8.3.x-dev
egouleau’s picture

in fact, Drupal seems to use the attribute hreflang on the "li" to add an "is-active" class on it in the language switcher block (without it, all the "li" in the language switcher are set "is-active")

if only it was named "data-hreflang" instead it would be W3C valid

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

ajzetat’s picture

StatusFileSize
new11.74 KB

When I tried to apply this patch, I got the following error message: "Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/attribute_hreflang_not-2454289-26.patch".
So I recreated the patch for the version of Drupal I am using (8.3.7).

Status: Needs review » Needs work

The last submitted patch, hreflang_attribute_not-2454289-43.patch, failed testing. View results

ajzetat’s picture

StatusFileSize
new9.38 KB

This is the new patch targeted against 8.5.x-dev.

ajzetat’s picture

This is the new patch targeted against 8.5.x-dev: hreflang_attribute_not-2454289-45.patch. Needs review.

pguillard’s picture

StatusFileSize
new9.38 KB

@ajzetat : Something got wrong with your patch updad ?

pguillard’s picture

Status: Needs work » Needs review
borisson_’s picture

Status: Needs review » Needs work

One small nitpick.

+++ b/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php
@@ -93,8 +92,8 @@ protected function doTestLanguageBlockAuthenticated($block_label) {
+      0 => array('langcode_class' => 'en'),
+      1 => array('langcode_class' => 'fr'),

This should use the short notation for arrays ([] instead of array())

pguillard’s picture

Status: Needs work » Needs review
StatusFileSize
new9.37 KB
new778 bytes

Applied suggestion at #49 by borisson_.

Status: Needs review » Needs work

The last submitted patch, 50: hreflang_attribute_not-2454289-50.patch, failed testing. View results

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

tipit’s picture

#50 applied to core 8.53 and fixed the issue according to https://validator.w3.org/nu/

pguillard’s picture

Status: Needs work » Needs review
Issue tags: -DevDaysMilan +DevDaysLisbon

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

rob holmes’s picture

This patch applies to 8.5.6 without issues and solves the problem and validation now passes. Would be nice to get this in.

laravz’s picture

The patch also applies to 8.6 with proper validation. However, I'm wondering whether we won't be breaking any functionality in the drupal.active-link library. Are we sure this is the way to go?

shamrockonov’s picture

StatusFileSize
new10.12 KB

Patch for use with 8.6.x

laravz’s picture

Patches should be applicable to 8.7.x now, so I've added a test for that.

rob holmes’s picture

StatusFileSize
new1.95 KB

Here is an alternative approach that wont affect the drupal.active-link library, (but probably breaks the active link library for all other links where the hreflang was on an actual a tag)

laravz’s picture

@Rob Holmes: If I understand correctly, patch #60 replaces the hreflang attribute with a custom HTML5 data attribute. I think there is a rule that states that data attributes should not be used if there is in fact already an existing attribute which is more appropriate for storing the data (language in this case). Hreflang is the more appropriate attribute even if it isn't allowed on a li element. Therefore, while applying this patch might resolve the w3c validation error, it would introduce another non-detectable 'error'.

rob holmes’s picture

That's a fair assessment,

Maybe we need a test for the active link library to ensure that nothing gets broken by any changes introduced by removing the hreflang from li elements?

laravz’s picture

That might be useful. The LanguageSwitchingTest seems to check some things with the active-link library, so I would say we're at least partway there. I've noticed that the library itself has a redundant variable initializer, but I'm not touching that since it has a big "DO NOT EDIT THIS FILE" warning in it.

Status: Needs review » Needs work

The last submitted patch, 60: 2454289-60.patch, failed testing. View results

laravz’s picture

The patch in #58 is functionally the same as the patch in #50, so I have no issues with that. However, issue #2713451 introduced a long comment stating why the 'is-active' class ha been placed on the li element. Apparently, it is needed to allow different styling on an active element. I'll ask the reporter of that issue to take a look at this issue.

joachim’s picture

> Apparently, it is needed to allow different styling on an active element.

That's pretty much the reason the 'is-active' class should be on the LI, and not just the A element. Sometimes you want to apply some sort of highlighting to the whole LI element.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

zulljin’s picture

Status: Needs work » Needs review
StatusFileSize
new3.21 KB

Hello, I update this solution, because when we get originalSelectors in this array get all the items, not only li. And as a result we get a bug through which the two elements are placed in the class "is-active".

Status: Needs review » Needs work

The last submitted patch, 68: 2454289-61.patch, failed testing. View results

zulljin’s picture

Status: Needs work » Needs review
StatusFileSize
new2.29 KB

Updated patch and fix problem with failing test.

Status: Needs review » Needs work

The last submitted patch, 70: 2454289-62.patch, failed testing. View results

zulljin’s picture

StatusFileSize
new3.29 KB

Fixed issue for not authentication users.

zulljin’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 72: 2454289-63.patch, failed testing. View results

mschudders’s picture

StatusFileSize
new715 bytes

I think for the original issue or question the solution is rather simple.
Please do tell me if I am forgetting something but in this patch I just removed the hreflang from the LI element.

rob holmes’s picture

@Mschudders while that technically fixes the validation error, it regresses the ability for Drupal.behaviors.activeLinks to highlight which language is the active one (which it does via javascript)

Any solution to this problem will have to provide valid HTML as well as retaining the ability to have a correctly applied .active class.

mschudders’s picture

StatusFileSize
new152.32 KB

Okay but I still see the is-active classes:

rob holmes’s picture

From the screenshot you have attached it looks like you have an .is-active class on the NL language as well as the EN Language links?

zulljin’s picture

@Mschudders, can you apply my patch #63? In this patch I fix bug when hreflang attributes missing in li elements. And ".is-active" sets correctly.

zulljin’s picture

Status: Needs work » Needs review
StatusFileSize
new22.58 KB

Changed the test ActiveLinkResponseFilterTest to validate the results.

Status: Needs review » Needs work

The last submitted patch, 80: 2454289-78.patch, failed testing. View results

zviryatko’s picture

StatusFileSize
new866 bytes
new22.79 KB

Fixed error in the test.

borisson_’s picture

Status: Needs work » Needs review

NR for testbot.

zviryatko’s picture

Please credit eugene.brit and ksemihin since they helped Zulljin locally in the office.

joseph.olstad’s picture

Status: Needs review » Reviewed & tested by the community

RTBC.
Patch 82 resolves the related accessibility issue and the test looks correct and corresponds to the changes required for w3c validation.

It also applies cleanly to head of 8.7.x and works correctly for 8.7.x as well.

Thanks

andrewmacpherson’s picture

Re #85 - what's the accessibility issue you refer to? It isn't mentioned anywhere earlier in the issue.

joseph.olstad’s picture

accessibility:
for the language switcher block in particular (our site is two languages English / French)
Language of Parts (Level AA)
1. All English pages: require (lang=”fr”) on Francais language toggle link
2. All French pages: require (lang=”en”) on English language toggle link

andrewmacpherson’s picture

@joseph.olstad - The issue summary here is about a HTML validation error, where <li hreflang="es"> isn't allowed. That has nothing to do with WCAG Language of Parts.

You can't solve Language of Parts with the hreflang attribute. The attribute indicates the language of the linked resource, but WCAG Language of Parts is concerned with the language of the link text. There's a separate issue to address this on the language switcher block - #3049122: Links in language switcher block do not conform to WCAG language-of-parts. I started to look into a solution for that, and noticed the HTML validation error on the containing <li> element, which led me to this issue.

I tried patch #82 with the specimen content in the Umami demo, and the language switcher block:

  • It does solve the HTML validation error from <li hreflang="es">.
  • It leaves the <a hreflang="es"> attribute in place on the link.
  • It doesn't solve the WCAG Language of Parts problem with the language switcher block. Specifically, it doesn't introduce any lang attributes. That's OK, because the issue summary here doesn't claim to fix that.

andrewmacpherson’s picture

andrewmacpherson’s picture

andrewmacpherson’s picture

Crediting eugene.brit and ksemihin per #84

andrewmacpherson’s picture

A couple of things which might need work. I don't know if they're important though, so I'm leaving it at RTBC.

  1. What's going on with the <li data-drupal-link-system-path> attribute? In #4, _nod suggested removing it from the list item. It's still there though. It looks like an earlier patch (#26) removed it, but by patch #82 it's come back.
  2. The new data-drupal-language attribute isn't very well explained.
alexpott’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new2.45 KB
new22.63 KB
+++ b/core/lib/Drupal/Core/EventSubscriber/ActiveLinkResponseFilter.php
@@ -187,7 +187,10 @@ public static function setLinkActiveClass($html_markup, $current_path, $is_front
-        if ($node->hasAttribute('hreflang') && $node->getAttribute('hreflang') !== $url_language) {
+        if ($node->nodeName !== 'a' && $node->hasAttribute('data-drupal-language') && $node->getAttribute('data-drupal-language') !== $url_language) {
+          $add_active = FALSE;
+        }
+        elseif ($node->nodeName === 'a' && $node->hasAttribute('hreflang') && $node->getAttribute('hreflang') !== $url_language) {
           $add_active = FALSE;
         }

I think we can tidy this up a bit by doing.

        $attribute = $node->nodeName === 'a' ? 'hreflang' : 'data-drupal-language';
        if ($node->hasAttribute($attribute) && $node->getAttribute($attribute) !== $url_language) {
          $add_active = FALSE;
        }

Also #82 had changes to the core/misc/active-link.js that were not build from core/misc/active-link.es6.js so I've fixed that.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

skymen’s picture

#95 not applied for drupal 9.0.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

joseph.olstad’s picture

StatusFileSize
new22.82 KB

Here is 95 rerolled for 9.0.x
hope the reroll is ok.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

olivier.br’s picture

StatusFileSize
new22.7 KB

reroll for 9.1.0

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

jaydarnell’s picture

Patch in comment #95 appears to work well for Drupal 8.9.14

joseph.olstad’s picture

needs a reroll for 9.0 and probably 9.1/9.2/9.3

paul_leclerc’s picture

Patch #95 in Drupal 8.9.19 makes my default links language switcher block having no more hreflang tag attributes on the li.
BUT it makes all li having an is-active class.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

alexiane dapsens’s picture

Patch #101 in Drupal 9.2.5 works fine, no more hreflang tag attributes on the li. And I do have the "is-active" class right on the li containing the displayed language link.

ranjith_kumar_k_u’s picture

StatusFileSize
new22.73 KB
new1.92 KB
nelo_drup’s picture

I just tried patch 101 and 109 and I am getting the following error.

My settings is:
Drupal Version
9.4.5

PHP
Version
7.4.30

Database MySQL
Version
5.7.39

Checking patch core/includes/theme.inc...
error: core/includes/theme.inc: No such file or directory
Checking patch core/lib/Drupal/Core/EventSubscriber/ActiveLinkResponseFilter.php...
error: core/lib/Drupal/Core/EventSubscriber/ActiveLinkResponseFilter.php: No such file or directory
Checking patch core/misc/active-link.es6.js...
error: core/misc/active-link.es6.js: No such file or directory
Checking patch core/misc/active-link.js...
error: core/misc/active-link.js: No such file or directory
Checking patch core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php...
error: core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php: No such file or directory

Note I am testing in a local environment and then upload to a shared server

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mfb’s picture

Patch #109 applies on 9.5.x, but needs a reroll for 10.1.x as core/misc/active-link.es6.js was renamed to core/misc/active-link.js

joseph.olstad’s picture

StatusFileSize
new20.43 KB

Rerolled 109:
This new patch works with D9.4.9 and D9.5.0

straight up reroll, I changed nothing except fix conflict rejects on hreflang substitute with data-drupal-language in
core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php

joseph.olstad’s picture

StatusFileSize
new20.5 KB

ok the CI framework is really picky, patch 113 is clean for D9.4.9 however it will work for D9.5.0 also

however to please the very picky CI framework that doesn't accept fuzz, I've got another D9.5.0 patch, 114

Status: Needs review » Needs work

The last submitted patch, 114: D95x_reroll-2454289-114.patch, failed testing. View results

eugene.brit’s picture

StatusFileSize
new19.5 KB

Re-roll #113 for 10.0.x

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

timohuisman’s picture

Status: Needs work » Needs review
StatusFileSize
new19.51 KB
new19.51 KB

Re-roll #116 against 10.1.x and 11.x. The custom commands failure from #116 should have been fixed.

The last submitted patch, 118: 2454289-118-10.1.x.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 118: 2454289-118-11.x.patch, failed testing. View results

nicrodgers’s picture

I've re-read through every comment in this issue and have observed the following:

data-drupal-link-system-path

in #4, @nod said

li element shouldn't have the data-drupal-link-system-path either.

in #94, @andrewmacpherson said

What's going on with the <li data-drupal-link-system-path> attribute? In #4, _nod suggested removing it from the list item. It's still there though. It looks like an earlier patch (#26) removed it, but by patch #82 it's come back.

This hasn't been addressed, so we need to decide whether this is something that needs to be done here or not, and update the issue summary and description accordingly.

data-drupal-language

in #94 @andrewmacpherson also said

The new data-drupal-language attribute isn't very well explained.

and this hasn't been addressed yet either.

failing tests in #118 need addressing

needs re-rolling

jonnyhocks’s picture

StatusFileSize
new20.01 KB
new20.01 KB

Here's the re-rolls for 10.3.x and 11.x - both based on #118

The other items from #121 remain outstanding.

berdir made their first commit to this issue’s fork.

berdir’s picture

Status: Needs work » Needs review

Created a merge request and adjusted the unit test.

I think changing data-drupal-link-system-path is out of scope. This was added on purpose in #1979468: ".active" from linkGenerator(), l() and theme_links() forces an upper limit of per-page caching for all content containing links and the concept of having the active class on li links has existed even before that. It's not broken and doesn't cause problems.

Not sure what/where to document on data-drupal-language, it's an internal attribute, like the other two, I don't think they are documented either.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Have not reviewed yet but issue summary could use some love

If you are another contributor eager to jump in, please allow the previous poster at least 48 hours to respond to feedback first, so they have the opportunity to finish what they started!

berdir’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update

Updated the issue summary. Didn't mention the discussion around the other data attributes, I don't really see how that's in scope. This doesn't change them in any way and we afaik specifically support active classes on list items.

smustgrave’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative
StatusFileSize
new27.06 KB
new19.1 KB

Hiding patches as the fix is in the MR,

Thanks for updating the issue summary.

Applying the MR and enabling the translation modules I am seeing the change being made see screenshots.

Before

before

After

after

Don't see any open threads or pending items right now. And nothing seems off in the code.

berdir’s picture

Rebased this, had to adjust script size. The diff is a bit misleading because other changes were already causing it to be very close to the upper limit of the 500 +/- range, the actual value before was 170941, now it is 171197 (which I rounded up to 171200), so a difference of 256.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

bakop’s picture

Assigned: Unassigned » bakop
Status: Needs work » Active
bakop’s picture

Assigned: bakop » Unassigned
Status: Active » Needs review
StatusFileSize
new6.34 KB

Hello, here is a patch for version 10.4.x that takes the same changes as the one made in 11.x

smustgrave’s picture

Status: Needs review » Needs work

Thanks but the issue has an MR already open and should be continued there

duaelfr made their first commit to this issue’s fork.

duaelfr’s picture

Status: Needs work » Needs review

Rerolled MR on latest 11.x

smustgrave’s picture

Status: Needs review » Needs work

Test failure seems related to change.

Any BC concern?

berdir’s picture

Status: Needs work » Needs review

Looks like other changes might have adjusted it again so it's close enough to the threshold, lets see if this passes.

This is a bugfix that removes invalid markup. It's a change, but it's a required one. You RTBC'd it 7 months ago, it just had a conflict and I missed it.

casey’s picture

StatusFileSize
new27.47 KB

Snapshot of latest state of MR for safe usage with composer patches for D11.2 projects

dcam’s picture

Status: Needs review » Reviewed & tested by the community

Using the command git diff bf76a69d I verified that the code is the same as that which was RTBCed back in March 2025 in comment #128. Subsequent changes to adjust the ScriptBytes in performance tests have been reverted. I'm restoring the RTBC status.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs change record

We should add a change record to detail what is changing here and the new data-drupal-language attribute.

I've considered the possible API impacts of this change and note that we're allowed to make markup changes in minor releases so this okay to go in 11.x - it might have missed 11.3.x but I think it is okay to go in 11.4.0 / 12.0.0 - will discuss with release managers if the CR is created and this is back to RTBC before 11.3.0-beta time...

dcam’s picture

Status: Needs work » Needs review
Issue tags: -Needs change record

I took a shot at adding a CR. Please review https://www.drupal.org/node/3556699.

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me, I tried to explain a bit better what exactly "invalid" means.

alexpott’s picture

Version: 11.x-dev » 11.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 7c721031d5d to 11.x and f0823b6cbb7 to 11.3.x. Thanks!

Decided to backport to 11.3.x as html changes are allowed and I've created contrib and I do not believe this will have an impact.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed f0823b6c on 11.3.x
    Issue #2454289 by laravz, pguillard, alexpott, ajzetat, borisson_,...

  • alexpott committed 7c721031 on 11.x
    Issue #2454289 by laravz, pguillard, alexpott, ajzetat, borisson_,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

joseph.olstad’s picture

Cool, one less patch, thanks!