diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 498c490beb..af36528c2d 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -639,15 +639,13 @@ function template_preprocess_datetime_wrapper(&$variables) { * associative array or a string. If it's an array, it can have the * following elements: * - text: The heading text. - * - level: The heading level (e.g. 'h2', 'h3'). * - attributes: (optional) An array of the CSS attributes for the heading. - * When using a string it will be used as the text of the heading and the - * level will default to 'h2'. Headings should be used on navigation menus - * and any list of links that consistently appears on multiple pages. To - * make the heading invisible use the 'visually-hidden' CSS class. Do not - * use 'display:none', which removes it from screen readers and assistive - * technology. Headings allow screen reader and keyboard only users to - * navigate to or skip the links. See + * When using a string it will be used as the text of the heading. + * Headings should be used on navigation menus and any list of links that + * consistently appears on multiple pages. To make the heading invisible use + * the 'visually-hidden' CSS class. Do not use 'display:none', which removes + * it from screen readers and assistive technology. Headings allow screen + * reader and keyboard only users to navigate to or skip the links. See * http://juicystudio.com/article/screen-readers-display-none.php and * http://www.w3.org/TR/WCAG-TECHS/H42.html for more information. * @@ -662,13 +660,12 @@ function template_preprocess_links(&$variables) { if (!empty($links)) { // Prepend the heading to the list, if any. if (!empty($heading)) { - // Convert a string heading into an array, using a

tag by default. + // Convert a string heading into an array. if (is_string($heading)) { $heading = ['text' => $heading]; } // Merge in default array properties into $heading. $heading += [ - 'level' => 'h2', 'attributes' => [], ]; // Convert the attributes array into an Attribute object. diff --git a/core/modules/system/src/Tests/Theme/FunctionsTest.php b/core/modules/system/src/Tests/Theme/FunctionsTest.php index a8fec41f21..707c540882 100644 --- a/core/modules/system/src/Tests/Theme/FunctionsTest.php +++ b/core/modules/system/src/Tests/Theme/FunctionsTest.php @@ -236,16 +236,15 @@ function testLinks() { // Verify that passing an array as heading works (core support). $variables['heading'] = [ 'text' => 'Links heading', - 'level' => 'h3', 'attributes' => ['class' => ['heading']], ]; - $expected_heading = '

Links heading

'; + $expected_heading = '

Links heading

'; $expected = $expected_heading . $expected_links; $this->assertThemeOutput('links', $variables, $expected); // Verify that passing attributes for the heading works. - $variables['heading'] = ['text' => 'Links heading', 'level' => 'h3', 'attributes' => ['id' => 'heading']]; - $expected_heading = '

Links heading

'; + $variables['heading'] = ['text' => 'Links heading', 'attributes' => ['id' => 'heading']]; + $expected_heading = '

Links heading

'; $expected = $expected_heading . $expected_links; $this->assertThemeOutput('links', $variables, $expected); @@ -357,16 +356,15 @@ function testIndexedKeyedLinks() { // Verify that passing an array as heading works (core support). $variables['heading'] = [ 'text' => 'Links heading', - 'level' => 'h3', 'attributes' => ['class' => ['heading']], ]; - $expected_heading = '

Links heading

'; + $expected_heading = '

Links heading

'; $expected = $expected_heading . $expected_links; $this->assertThemeOutput('links', $variables, $expected); // Verify that passing attributes for the heading works. - $variables['heading'] = ['text' => 'Links heading', 'level' => 'h3', 'attributes' => ['id' => 'heading']]; - $expected_heading = '

Links heading

'; + $variables['heading'] = ['text' => 'Links heading', 'attributes' => ['id' => 'heading']]; + $expected_heading = '

Links heading

'; $expected = $expected_heading . $expected_links; $this->assertThemeOutput('links', $variables, $expected); diff --git a/core/modules/system/templates/links.html.twig b/core/modules/system/templates/links.html.twig index 62e9ed0b57..24912d6757 100644 --- a/core/modules/system/templates/links.html.twig +++ b/core/modules/system/templates/links.html.twig @@ -15,10 +15,8 @@ * tag if no 'url' is supplied. * - heading: (optional) A heading to precede the links. * - text: The heading text. - * - level: The heading level (e.g. 'h2', 'h3'). * - attributes: (optional) A keyed list of attributes for the heading. - * If the heading is a string, it will be used as the text of the heading and - * the level will default to 'h2'. + * If the heading is a string, it will be used as the text of the heading. * * Headings should be used on navigation menus and any list of links that * consistently appears on multiple pages. To make the heading invisible use diff --git a/core/themes/classy/templates/content/links--node.html.twig b/core/themes/classy/templates/content/links--node.html.twig index a7b91e7103..b2d50e751c 100644 --- a/core/themes/classy/templates/content/links--node.html.twig +++ b/core/themes/classy/templates/content/links--node.html.twig @@ -15,10 +15,8 @@ * tag if no 'href' is supplied. * - heading: (optional) A heading to precede the links. * - text: The heading text. - * - level: The heading level (e.g. 'h2', 'h3'). * - attributes: (optional) A keyed list of attributes for the heading. - * If the heading is a string, it will be used as the text of the heading and - * the level will default to 'h2'. + * If the heading is a string, it will be used as the text of the heading. * * Headings should be used on navigation menus and any list of links that * consistently appears on multiple pages. To make the heading invisible use diff --git a/core/themes/classy/templates/navigation/links.html.twig b/core/themes/classy/templates/navigation/links.html.twig index c1bff6bfb5..104f846196 100644 --- a/core/themes/classy/templates/navigation/links.html.twig +++ b/core/themes/classy/templates/navigation/links.html.twig @@ -15,10 +15,8 @@ * tag if no 'href' is supplied. * - heading: (optional) A heading to precede the links. * - text: The heading text. - * - level: The heading level (e.g. 'h2', 'h3'). * - attributes: (optional) A keyed list of attributes for the heading. - * If the heading is a string, it will be used as the text of the heading and - * the level will default to 'h2'. + * If the heading is a string, it will be used as the text of the heading. * * Headings should be used on navigation menus and any list of links that * consistently appears on multiple pages. To make the heading invisible use @@ -33,11 +31,7 @@ #} {% if links -%} {%- if heading -%} - {%- if heading.level -%} - <{{ heading.level }}{{ heading.attributes }}>{{ heading.text }} - {%- else -%} - {{ heading.text }} - {%- endif -%} + {{ heading.text }} {%- endif -%} {%- for item in links -%} diff --git a/core/themes/stable/templates/navigation/links.html.twig b/core/themes/stable/templates/navigation/links.html.twig index c1bff6bfb5..104f846196 100644 --- a/core/themes/stable/templates/navigation/links.html.twig +++ b/core/themes/stable/templates/navigation/links.html.twig @@ -15,10 +15,8 @@ * tag if no 'href' is supplied. * - heading: (optional) A heading to precede the links. * - text: The heading text. - * - level: The heading level (e.g. 'h2', 'h3'). * - attributes: (optional) A keyed list of attributes for the heading. - * If the heading is a string, it will be used as the text of the heading and - * the level will default to 'h2'. + * If the heading is a string, it will be used as the text of the heading. * * Headings should be used on navigation menus and any list of links that * consistently appears on multiple pages. To make the heading invisible use @@ -33,11 +31,7 @@ #} {% if links -%} {%- if heading -%} - {%- if heading.level -%} - <{{ heading.level }}{{ heading.attributes }}>{{ heading.text }} - {%- else -%} - {{ heading.text }} - {%- endif -%} + {{ heading.text }} {%- endif -%} {%- for item in links -%}