Commit decb9b1c authored by alexpott's avatar alexpott

Issue #2544162 by StryKaizer, lauriii, Wim Leers, LewisNyman, jcnventura,...

Issue #2544162 by StryKaizer, lauriii, Wim Leers, LewisNyman, jcnventura, willzyx, dawehner: Dropbutton library is only loaded on cache rebuild
parent 6fb9d191
......@@ -684,7 +684,17 @@ protected function renderFields(array $result) {
'#cache_properties' => $field_ids,
];
$renderer->addCacheableDependency($data, $this->view->storage);
$renderer->renderPlain($data);
// Views may be rendered both inside and outside a render context:
// - HTML views are rendered inside a render context: then we want to
// use ::render(), so that attachments and cacheability are bubbled.
// - non-HTML views are rendered outside a render context: then we
// want to use ::renderPlain(), so that no bubbling happens
if ($renderer->hasRenderContext()) {
$renderer->render($data);
}
else {
$renderer->renderPlain($data);
}
// Extract field output from the render array and post process it.
$fields = $this->view->field;
......
......@@ -31,6 +31,16 @@ class FieldDropButtonTest extends HandlerTestBase {
*/
public static $modules = array('node');
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$admin_user = $this->drupalCreateUser(['access content overview', 'administer nodes', 'bypass node access']);
$this->drupalLogin($admin_user);
}
/**
* Tests dropbutton field.
*/
......@@ -48,6 +58,14 @@ public function testDropbutton() {
$result = $this->xpath('//ul[contains(@class, dropbutton)]/li/a[contains(@href, :path) and text()=:title]', array(':path' => '/node/' . $node->id(), ':title' => t('Custom Text')));
$this->assertEqual(count($result), 1, 'Just one custom link was found.');
}
// Check if the dropbutton.js library is available.
$this->drupalGet('admin/content');
$this->assertRaw('dropbutton.js');
// Check if the dropbutton.js library is available on a cached page to
// ensure that bubbleable metadata is not lost in the views render workflow.
$this->drupalGet('admin/content');
$this->assertRaw('dropbutton.js');
}
}
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