Commit 3d0a938e authored by alexpott's avatar alexpott

Issue #2529748 by Chernous_dn, jhedstrom, cilefen, davidhernandez, olli, dpi,...

Issue #2529748 by Chernous_dn, jhedstrom, cilefen, davidhernandez, olli, dpi, pixelite, dawehner, jhodgdon: Regression: Views module CSS is not attached
parent f26b0658
...@@ -51,6 +51,7 @@ public static function preRenderViewElement($element) { ...@@ -51,6 +51,7 @@ public static function preRenderViewElement($element) {
$view = $element['#view']; $view = $element['#view'];
} }
$element += $view->element;
$view->element = &$element; $view->element = &$element;
// Mark the element as being prerendered, so other code like // Mark the element as being prerendered, so other code like
// \Drupal\views\ViewExecutable::setCurrentPage knows that its no longer // \Drupal\views\ViewExecutable::setCurrentPage knows that its no longer
......
...@@ -51,6 +51,10 @@ public function testGrid() { ...@@ -51,6 +51,10 @@ public function testGrid() {
$this->assertGrid($view, $alignment, 2); $this->assertGrid($view, $alignment, 2);
$this->assertGrid($view, $alignment, 1); $this->assertGrid($view, $alignment, 1);
} }
// Ensure styles are properly added for grid views.
$this->drupalGet('test-grid');
$this->assertRaw('views/css/views.module.css');
} }
/** /**
......
...@@ -55,13 +55,12 @@ public function testAjaxView() { ...@@ -55,13 +55,12 @@ public function testAjaxView() {
$data = Json::decode($response); $data = Json::decode($response);
$this->assertTrue(isset($data[0]['settings']['views']['ajaxViews'])); $this->assertTrue(isset($data[0]['settings']['views']['ajaxViews']));
$this->assertEqual($data[1]['command'], 'add_css');
// Ensure that the view insert command is part of the result. // Ensure that the view insert command is part of the result.
$this->assertEqual($data[2]['command'], 'insert'); $this->assertEqual($data[1]['command'], 'insert');
$this->assertTrue(strpos($data[2]['selector'], '.js-view-dom-id-') === 0); $this->assertTrue(strpos($data[1]['selector'], '.js-view-dom-id-') === 0);
$this->setRawContent($data[2]['data']); $this->setRawContent($data[1]['data']);
$result = $this->xpath('//div[contains(@class, "views-row")]'); $result = $this->xpath('//div[contains(@class, "views-row")]');
$this->assertEqual(count($result), 2, 'Ensure that two items are rendered in the HTML.'); $this->assertEqual(count($result), 2, 'Ensure that two items are rendered in the HTML.');
} }
......
...@@ -403,7 +403,7 @@ class ViewExecutable implements \Serializable { ...@@ -403,7 +403,7 @@ class ViewExecutable implements \Serializable {
*/ */
public $element = [ public $element = [
'#attached' => [ '#attached' => [
'library' => [], 'library' => ['views/views.module'],
'drupalSettings' => [], 'drupalSettings' => [],
], ],
'#cache' => [], '#cache' => [],
...@@ -456,9 +456,6 @@ public function __construct(ViewEntityInterface $storage, AccountInterface $user ...@@ -456,9 +456,6 @@ public function __construct(ViewEntityInterface $storage, AccountInterface $user
$this->user = $user; $this->user = $user;
$this->viewsData = $views_data; $this->viewsData = $views_data;
$this->routeProvider = $route_provider; $this->routeProvider = $route_provider;
// Add the default css for a view.
$this->element['#attached']['library'][] = 'views/views.module';
} }
/** /**
......
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