Commit d997d397 authored by alexpott's avatar alexpott

Issue #2547811 by nlisgo, borisson_, davidhernandez, dawehner, mansspams:...

Issue #2547811 by nlisgo, borisson_, davidhernandez, dawehner, mansspams: Header and footer are appearing in markup when they should be empty
parent 997da33d
......@@ -2217,7 +2217,9 @@ public function elementPreRender(array $element) {
public function renderArea($area, $empty = FALSE) {
$return = array();
foreach ($this->getHandlers($area) as $key => $area_handler) {
$return[$key] = $area_handler->render($empty);
if ($area_render = $area_handler->render($empty)) {
$return[$key] = $area_render;
}
}
return $return;
}
......
......@@ -115,6 +115,41 @@ public function testRenderArea() {
$this->assertTrue(strpos($output, '<script') === FALSE, 'Script tags were escaped');
}
/**
* Tests that the header and footer areas are not rendered if empty.
*/
public function testRenderEmptyHeaderFooter() {
$view = Views::getView('test_example_area');
$view->initHandlers();
// Set example empty text.
$view->empty['test_example']->options['string'] = '<p>' . $this->randomMachineName() . '</p>';
$xpath = '//div[contains(@class, :class)]';
// Verify that the empty header and footer sections have not been rendered.
$output = $view->preview();
$html = $this->container->get('renderer')->renderRoot($output);
$this->setRawContent($html);
$this->assertEqual(0, count($this->xpath($xpath, [':class' => 'view-header'])));
$this->assertEqual(0, count($this->xpath($xpath, [':class' => 'view-footer'])));
// Set example header text.
$view->header['test_example']->options['string'] = '<p>' . $this->randomMachineName() . '</p>';
$view->header['test_example']->options['empty'] = TRUE;
// Set example footer text.
$view->footer['test_example']->options['string'] = '<p>' . $this->randomMachineName() . '</p>';
$view->footer['test_example']->options['empty'] = TRUE;
// Verify that the header and footer sections have been rendered.
$output = $view->preview();
$html = $this->container->get('renderer')->renderRoot($output);
$this->setRawContent($html);
$this->assertEqual(1, count($this->xpath($xpath, [':class' => 'view-header'])));
$this->assertEqual(1, count($this->xpath($xpath, [':class' => 'view-footer'])));
}
/**
* Tests the access for an area.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment