Issue #2547811 by nlisgo, borisson_, davidhernandez, dawehner, mansspams: Header and footer are appearing in markup when they should be empty
parent
997da33d6c
commit
d997d39712
|
@ -2217,7 +2217,9 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
|
||||||
public function renderArea($area, $empty = FALSE) {
|
public function renderArea($area, $empty = FALSE) {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach ($this->getHandlers($area) as $key => $area_handler) {
|
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;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,6 +115,41 @@ class AreaTest extends HandlerTestBase {
|
||||||
$this->assertTrue(strpos($output, '<script') === FALSE, 'Script tags were escaped');
|
$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.
|
* Tests the access for an area.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue