summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2018-06-15 12:35:53 (GMT)
committerNathaniel Catchpole2018-06-15 12:35:53 (GMT)
commit2f9be00c67a916019fe84e3f5931f9f9bec4fc12 (patch)
tree07f1087c33a2c58ebc3a3636bab4322a3ef56cc0
parente7f061d5d40dca7b4aafabf903652fab1cd436ab (diff)
Issue #2736391 by LoMo, rooby, lauriii, leolando.tan: Node type body class is not present on node preview page
-rw-r--r--core/modules/node/node.module9
-rw-r--r--core/modules/node/src/Tests/PagePreviewTest.php4
2 files changed, 10 insertions, 3 deletions
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index ea27e26..818fc89 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -547,9 +547,12 @@ function template_preprocess_node_add_list(&$variables) {
* Implements hook_preprocess_HOOK() for HTML document templates.
*/
function node_preprocess_html(&$variables) {
- // If on an individual node page, add the node type to body classes.
- if (($node = \Drupal::routeMatch()->getParameter('node')) && $node instanceof NodeInterface) {
- $variables['node_type'] = $node->getType();
+ // If on an individual node page or node preview page, add the node type to
+ // the body classes.
+ if (($node = \Drupal::routeMatch()->getParameter('node')) || ($node = \Drupal::routeMatch()->getParameter('node_preview'))) {
+ if ($node instanceof NodeInterface) {
+ $variables['node_type'] = $node->getType();
+ }
}
}
diff --git a/core/modules/node/src/Tests/PagePreviewTest.php b/core/modules/node/src/Tests/PagePreviewTest.php
index bcbe5d7..2bc9cd3 100644
--- a/core/modules/node/src/Tests/PagePreviewTest.php
+++ b/core/modules/node/src/Tests/PagePreviewTest.php
@@ -183,6 +183,10 @@ class PagePreviewTest extends NodeTestBase {
$this->assertText($edit[$term_key], 'Term displayed.');
$this->assertLink(t('Back to content editing'));
+ // Check that we see the class of the node type on the body element.
+ $body_class_element = $this->xpath("//body[contains(@class, 'page-node-type-page')]");
+ $this->assertTrue(!empty($body_class_element), 'Node type body class found.');
+
// Get the UUID.
$url = parse_url($this->getUrl());
$paths = explode('/', $url['path']);