diff --git a/core/modules/language/language.module b/core/modules/language/language.module index dba38c258990ef355af9f0cae2197e54ba7e5a4e..fb2bfdc9c2ef3091687e79acfd87d496cb2e8ac1 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -126,15 +126,6 @@ function language_negotiation_url_prefixes_update() { $config->set('url.prefixes', $prefixes)->save(TRUE); } -/** - * Implements hook_preprocess_HOOK() for block templates. - */ -function language_preprocess_block(&$variables): void { - if ($variables['configuration']['provider'] == 'language') { - $variables['attributes']['role'] = 'navigation'; - } -} - /** * Returns language mappings between browser and Drupal language codes. * diff --git a/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php b/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php index 32ec3a2c6e51f23856bdd0e230475b8f94fc9297..b6001f2be79d2341011b5da74835fb093946b305 100644 --- a/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php +++ b/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php @@ -84,6 +84,7 @@ public function testLanguageBlock(): void { ]); $this->doTestLanguageBlockAuthenticated($block->label()); + $this->doTestLanguageBlockRole($block->label()); $this->doTestHomePageLinks($block->label()); $this->doTestLanguageBlockAnonymous($block->label()); $this->doTestLanguageBlock404($block->label(), 'system/404'); @@ -211,6 +212,26 @@ protected function doTestLanguageBlockAuthenticated($block_label): void { $this->assertSame(['English', 'français'], $labels, 'The language links labels are in their own language on the language switcher block.'); } + /** + * Verifies that the block does not have the navigation role attribute. + * + * @param string $block_label + * The label of the language switching block. + * + * @see self::testLanguageBlock() + */ + protected function doTestLanguageBlockRole($block_label): void { + // Assert that the language switching block is displayed on the frontpage. + $this->drupalGet(''); + $this->assertSession()->pageTextContains($block_label); + + $block = $this->xpath('//div[@id=:id][not(@role=:role)]', [ + ':id' => 'block-test-language-block', + ':role' => 'navigation', + ]); + $this->assertCount(1, $block); + } + /** * For anonymous users, the "active" class is set by PHP. *