diff --git a/core/modules/locale/src/Tests/LocaleContentTest.php b/core/modules/locale/src/Tests/LocaleContentTest.php index 3ec3c71..4c628fa 100644 --- a/core/modules/locale/src/Tests/LocaleContentTest.php +++ b/core/modules/locale/src/Tests/LocaleContentTest.php @@ -177,26 +177,26 @@ public function testContentTypeDirLang() { // Check if English node does not have lang tag. $this->drupalGet('node/' . $nodes['en']->id()); - $pattern = '|class="[^"]*node[^"]*"[^<>]*lang="en"|'; - $this->assertNoPattern($pattern, 'The lang tag has not been assigned to the English node.'); + $element = $this->cssSelect('article.node[lang="en"]'); + $this->assertTrue(empty($element), 'The lang tag has not been assigned to the English node.'); // Check if English node does not have dir tag. - $pattern = '|class="[^"]*node[^"]*"[^<>]*dir="ltr"|'; - $this->assertNoPattern($pattern, 'The dir tag has not been assigned to the English node.'); + $element = $this->cssSelect('article.node[dir="ltr"]'); + $this->assertTrue(empty($element), 'The dir tag has not been assigned to the English node.'); // Check if Arabic node has lang="ar" & dir="rtl" tags. $this->drupalGet('node/' . $nodes['ar']->id()); - $pattern = '|class="[^"]*node[^"]*"[^<>]*lang="ar" dir="rtl"|'; - $this->assertPattern($pattern, 'The lang and dir tags have been assigned correctly to the Arabic node.'); + $element = $this->cssSelect('article.node[lang="ar"][dir="rtl"]'); + $this->assertTrue(!empty($element), 'The lang and dir tags have been assigned correctly to the Arabic node.'); // Check if Spanish node has lang="es" tag. $this->drupalGet('node/' . $nodes['es']->id()); - $pattern = '|class="[^"]*node[^"]*"[^<>]*lang="es"|'; - $this->assertPattern($pattern, 'The lang tag has been assigned correctly to the Spanish node.'); + $element = $this->cssSelect('article.node[lang="es"]'); + $this->assertTrue(!empty($element), 'The lang tag has been assigned correctly to the Spanish node.'); // Check if Spanish node does not have dir="ltr" tag. - $pattern = '|class="[^"]*node[^"]*"[^<>]*lang="es" dir="ltr"|'; - $this->assertNoPattern($pattern, 'The dir tag has not been assigned to the Spanish node.'); + $element = $this->cssSelect('article.node[lang="es"][dir="ltr"]'); + $this->assertTrue(empty($element), 'The dir tag has not been assigned to the Spanish node.'); } } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index d96052d..751663a 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -651,25 +651,6 @@ function template_preprocess_node(&$variables) { // Add article ARIA role. $variables['attributes']['role'] = 'article'; - - // Gather node classes. - $variables['attributes']['class'][] = 'node'; - $variables['attributes']['class'][] = drupal_html_class('node--type-' . $node->bundle()); - if ($node->isPromoted()) { - $variables['attributes']['class'][] = 'node--promoted'; - } - if ($node->isSticky()) { - $variables['attributes']['class'][] = 'node--sticky'; - } - if (!$node->isPublished()) { - $variables['attributes']['class'][] = 'node--unpublished'; - } - if ($variables['view_mode']) { - $variables['attributes']['class'][] = drupal_html_class('node--view-mode-' . $variables['view_mode']); - } - if (isset($node->preview)) { - $variables['attributes']['class'][] = 'node--preview'; - } } /** diff --git a/core/modules/node/templates/node.html.twig b/core/modules/node/templates/node.html.twig index a08b064..bfce74f 100644 --- a/core/modules/node/templates/node.html.twig +++ b/core/modules/node/templates/node.html.twig @@ -11,10 +11,6 @@ * - createdtime: Formatted creation date. Preprocess functions can * reformat it by calling format_date() with the desired parameters on * $variables['node']->getCreatedTime(). - * - promoted: Whether the node is promoted to the front page. - * - sticky: Whether the node is 'sticky'. Sticky nodes are ordered above - * other non-sticky nodes in teaser listings - * - published: Whether the node is published. * - label: The title of the node. * - content: All node items. Use {{ content }} to print them all, * or print a subset such as {{ content.field_example }}. Use @@ -33,8 +29,8 @@ * The attributes.class element may contain one or more of the following * classes: * - node: The current template type (also known as a "theming hook"). - * - node--[type]: The current node type. For example, if the node is a - * "Article" it would result in "node--article". Note that the machine + * - node--type-[type]: The current node type. For example, if the node is a + * "Article" it would result in "node--type-article". Note that the machine * name will often be in a short form of the human readable label. * - node--view-mode-[view_mode]: The View Mode of the node; for example, a * teaser would result in: "node--view-mode-teaser", and @@ -76,7 +72,17 @@ * @ingroup themeable */ #} - +{% + set classes = [ + 'node', + 'node--type-' ~ node.bundle|clean_class, + node.isPromoted() ? 'node--promoted', + node.isSticky() ? 'node--sticky', + not node.isPublished() ? 'node--unpublished', + view_mode ? 'node--view-mode-' ~ view_mode|clean_class, + ] +%} + {{ title_prefix }} {% if not page %} @@ -89,14 +95,14 @@ {% if display_submitted %}
{{ author_picture }} -
{% endif %} -
+ {{ content|without('links') }}
diff --git a/core/themes/bartik/templates/node.html.twig b/core/themes/bartik/templates/node.html.twig index d45b0f0..57297c6 100644 --- a/core/themes/bartik/templates/node.html.twig +++ b/core/themes/bartik/templates/node.html.twig @@ -11,15 +11,11 @@ * - createdtime: Formatted creation date. Preprocess functions can * reformat it by calling format_date() with the desired parameters on * $variables['node']->getCreatedTime(). - * - promoted: Whether the node is promoted to the front page. - * - sticky: Whether the node is 'sticky'. Sticky nodes are ordered above - * other non-sticky nodes in teaser listings - * - published: Whether the node is published. * - label: The title of the node. * - content: All node items. Use {{ content }} to print them all, * or print a subset such as {{ content.field_example }}. Use - * {{ content|without('field_example') }} to exclude the printing of a - * given child element. + * {{ content|without('field_example') %} to temporarily suppress the printing + * of a given child element. * - author_picture: The node author user entity, rendered using the "compact" * view mode. * - metadata: Metadata for this node. @@ -33,13 +29,12 @@ * The attributes.class element may contain one or more of the following * classes: * - node: The current template type (also known as a "theming hook"). - * - node--[type]: The current node type. For example, if the node is a - * "Article" it would result in "node--article". Note that the machine + * - node--type-[type]: The current node type. For example, if the node is a + * "Article" it would result in "node--type-article". Note that the machine * name will often be in a short form of the human readable label. * - node--view-mode-[view_mode]: The View Mode of the node; for example, a - * teaser would result in: "node--view-mode-teaser", - * and full: "node--view-mode-full". - * - is-preview: Whether a node is in preview mode. + * teaser would result in: "node--view-mode-teaser", and + * full: "node--view-mode-full". * The following are controlled through the node publishing options. * - node--promoted: Appears on nodes promoted to the front page. * - node--sticky: Appears on nodes ordered above other non-sticky nodes in @@ -71,12 +66,23 @@ * @see template_preprocess_node() */ #} -
+{% + set classes = [ + 'node', + 'node--type-' ~ node.bundle|clean_class, + node.isPromoted() ? 'node--promoted', + node.isSticky() ? 'node--sticky', + not node.isPublished() ? 'node--unpublished', + view_mode ? 'node--view-mode-' ~ view_mode|clean_class, + 'clearfix', + ] +%} +
{{ title_prefix }} {% if not page %} -

+ {{ label }}

{% endif %} @@ -93,7 +99,7 @@ {% endif %}
-
+ {{ content|without('comment', 'links') }}