diff --git a/core/includes/pager.inc b/core/includes/pager.inc index a711823..b653209 100644 --- a/core/includes/pager.inc +++ b/core/includes/pager.inc @@ -219,13 +219,9 @@ function template_preprocess_pager(&$variables) { if ($pager_total[$element] > 1) { // Create the "first" and "previous" links if we are not on the first page. if ($pager_page_array[$element] > 0) { - $li_first = pager_query_add_page($parameters, $element, 0); + $items['first'] = true; $li_previous = pager_query_add_page($parameters, $element, $pager_page_array[$element] - 1); - if ($li_first) { - $items['first'] = true; - } - if ($li_previous && isset($li_previous['page'])) { $items['previous'] = $li_previous['page']; } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php index 161d215..b27d4e0 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php @@ -95,7 +95,7 @@ public function testFeedPage() { // Check for presence of an aggregator pager. $this->drupalGet('aggregator'); - $elements = $this->xpath("//ul[@class=:class]", array(':class' => 'pager')); + $elements = $this->xpath("//ul[@class=:class]", array(':class' => 'pager__items')); $this->assertTrue(!empty($elements), 'Individual source page contains a pager.'); // Check for sources page title. @@ -110,7 +110,7 @@ public function testFeedPage() { // Check for the presence of a pager. $this->drupalGet('aggregator/sources/' . $feed->id()); - $elements = $this->xpath("//ul[@class=:class]", array(':class' => 'pager')); + $elements = $this->xpath("//ul[@class=:class]", array(':class' => 'pager__items')); $this->assertTrue(!empty($elements), 'Individual source page contains a pager.'); } } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentPagerTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentPagerTest.php index d1e447bf..ea9b55e 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentPagerTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentPagerTest.php @@ -333,19 +333,19 @@ function testTwoPagers() { $this->assertRaw('Comment 1 on field comment'); $this->assertRaw('Comment 1 on field comment_2'); // Navigate to next page of field 1. - $this->clickLink('next ›'); + $this->clickLink('Next page'); // Check only one pager updated. $this->assertRaw('Comment 2 on field comment'); $this->assertRaw('Comment 1 on field comment_2'); // Return to page 1. $this->drupalGet('node/' . $node->id()); // Navigate to next page of field 2. - $this->clickLink('next ›', 1); + $this->clickLink('Next page', 1); // Check only one pager updated. $this->assertRaw('Comment 1 on field comment'); $this->assertRaw('Comment 2 on field comment_2'); // Navigate to next page of field 1. - $this->clickLink('next ›'); + $this->clickLink('Next page'); // Check only one pager updated. $this->assertRaw('Comment 2 on field comment'); $this->assertRaw('Comment 2 on field comment_2'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php b/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php index 845aa28..51aea36 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php @@ -60,10 +60,10 @@ function testActiveClass() { $this->assertPagerItems($current_page); // Verify last page. - $elements = $this->xpath('//li[contains(@class, :class)]/a', array(':class' => 'pager-last')); + $elements = $this->xpath('//li/a[contains(@rel, :rel)]', array(':rel' => 'next')); preg_match('@page=(\d+)@', $elements[0]['href'], $matches); $current_page = (int) $matches[1]; - $this->drupalGet($GLOBALS['base_root'] . $elements[0]['href'], array('external' => TRUE)); + $this->drupalGet($elements[0]['href']); $this->assertPagerItems($current_page); } @@ -74,7 +74,7 @@ function testActiveClass() { * The current pager page the internal browser is on. */ protected function assertPagerItems($current_page) { - $elements = $this->xpath('//ul[@class=:class]/li', array(':class' => 'pager')); + $elements = $this->xpath('//ul[@class=:class]/li', array(':class' => 'pager__items')); $this->assertTrue(!empty($elements), 'Pager found.'); // Make current page 1-based. @@ -97,14 +97,14 @@ protected function assertPagerItems($current_page) { // Make item/page index 1-based. $page++; if ($current_page == $page) { - $this->assertClass($element, 'pager-current', 'Item for current page has .pager-current class.'); - $this->assertFalse(isset($element->a), 'Item for current page has no link.'); + $this->assertClass($element, 'is-active', 'Item for current page has .is-active class.'); + $this->assertTrue(isset($element->a), 'Item for current page has link.'); } else { - $this->assertNoClass($element, 'pager-current', "Item for page $page has no .pager-current class."); - $this->assertClass($element, 'pager-item', "Item for page $page has .pager-item class."); + $this->assertNoClass($element, 'is-active', "Item for page $page has no .is-active class."); + //$this->assertClass($element, 'pager-item', "Item for page $page has .pager-item class."); $this->assertTrue($element->a, "Link to page $page found."); - $this->assertNoClass($element->a, 'active', "Link to page $page is not active."); + $this->assertNoClass($element, 'is-active', "Link to page $page is not active."); } unset($elements[--$page]); } @@ -113,24 +113,24 @@ protected function assertPagerItems($current_page) { // Verify first/previous and next/last items and links. if (isset($first)) { - $this->assertClass($first, 'pager-first', 'Item for first page has .pager-first class.'); + $this->assertClass($first->a->i, 'icon--go-first', 'Item for first page has .icon--go-first class.'); $this->assertTrue($first->a, 'Link to first page found.'); - $this->assertNoClass($first->a, 'active', 'Link to first page is not active.'); + $this->assertNoClass($first, 'is-active', 'Link to first page is not active.'); } if (isset($previous)) { - $this->assertClass($previous, 'pager-previous', 'Item for first page has .pager-previous class.'); + $this->assertClass($previous->a->i, 'icon--go-previous', 'Item for first page has .icon--go-previous class.'); $this->assertTrue($previous->a, 'Link to previous page found.'); - $this->assertNoClass($previous->a, 'active', 'Link to previous page is not active.'); + $this->assertNoClass($previous, 'is-active', 'Link to previous page is not active.'); } if (isset($next)) { - $this->assertClass($next, 'pager-next', 'Item for next page has .pager-next class.'); + $this->assertClass($next->a->i, 'icon--go-next', 'Item for next page has .icon--go-next class.'); $this->assertTrue($next->a, 'Link to next page found.'); - $this->assertNoClass($next->a, 'active', 'Link to next page is not active.'); + $this->assertNoClass($next, 'is-active', 'Link to next page is not active.'); } if (isset($last)) { - $this->assertClass($last, 'pager-last', 'Item for last page has .pager-last class.'); + $this->assertClass($last->a->i, 'icon--go-last', 'Item for last page has .icon--go-last class.'); $this->assertTrue($last->a, 'Link to last page found.'); - $this->assertNoClass($last->a, 'active', 'Link to last page is not active.'); + $this->assertNoClass($last, 'is-active', 'Link to last page is not active.'); } } diff --git a/core/modules/system/templates/item-list--pager.html.twig b/core/modules/system/templates/item-list--pager.html.twig new file mode 100644 index 0000000..e8d16e0 --- /dev/null +++ b/core/modules/system/templates/item-list--pager.html.twig @@ -0,0 +1,36 @@ +{# +/** + * @file + * Default theme implementation for an item list. + * + * Available variables: + * - items: A list of renderable items. Each item has a #wrapper_attributes + * property which contains any HTML attributes which should be applied to the + *
  • tag. + * - title: The title of the list. + * - list_type: The tag for list element ("ul" or "ol"). + * - attributes: HTML attributes to be applied to the list. + * - empty: A message to display when there are no items. Allowed value is a + * string or render array. + * + * @see template_preprocess_item_list() + * + * @ingroup themeable + */ +#} +{%- if items or empty -%} +
    + {%- if title -%} +

    {{ title }}

    + {%- endif -%} + {%- if items -%} + <{{ list_type }}{{ attributes }}> + {%- for item in items -%} + {{ item.value }}
  • + {%- endfor -%} + + {%- else -%} + {{- empty -}} + {%- endif -%} + +{%- endif %} diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php index 01feff6..e6e57c4 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/PreviewTest.php @@ -110,58 +110,53 @@ public function testPreviewWithPagersUI() { $this->getPreviewAJAX('test_pager_full', 'default', 5); // Test that the pager is present and rendered. - $elements = $this->xpath('//ul[@class = "pager"]/li'); + $elements = $this->xpath('//ul[@class = "pager__items"]/li'); $this->assertTrue(!empty($elements), 'Full pager found.'); // Verify elements and links to pages. // We expect to find 5 elements: current page == 1, links to pages 2 and // and 3, links to 'next >' and 'last >>' pages. - $this->assertClass($elements[0], 'pager-current', 'Element for current page has .pager-current class.'); - $this->assertFalse(isset($elements[0]->a), 'Element for current page has no link.'); + $this->assertClass($elements[0], 'is-active', 'Element for current page has .is-active class.'); - $this->assertClass($elements[1], 'pager-item', "Element for page 2 has .pager-item class."); $this->assertTrue($elements[1]->a, "Link to page 2 found."); - $this->assertClass($elements[2], 'pager-item', "Element for page 3 has .pager-item class."); $this->assertTrue($elements[2]->a, "Link to page 3 found."); - $this->assertClass($elements[3], 'pager-next', "Element for next page has .pager-next class."); + $this->assertClass($elements[3]->a->i, 'icon--go-next', "Element for next page has .icon--go-next class."); $this->assertTrue($elements[3]->a, "Link to next page found."); - $this->assertClass($elements[4], 'pager-last', "Element for last page has .pager-last class."); + $this->assertClass($elements[4]->a->i, 'icon--go-last', "Element for last page has .icon--go-last class."); $this->assertTrue($elements[4]->a, "Link to last page found."); // Navigate to next page. - $elements = $this->xpath('//li[contains(@class, :class)]/a', array(':class' => 'pager-next')); - $this->clickPreviewLinkAJAX($elements[0]['href'], 5); + //$elements = $this->xpath('//li/a/i[contains(@class, :class)]', array(':class' => 'icon--go-next')); + $this->clickPreviewLinkAJAX($elements[3]->a['href'], 5); // Test that the pager is present and rendered. - $elements = $this->xpath('//ul[@class = "pager"]/li'); + $elements = $this->xpath('//ul[@class = "pager__items"]/li'); $this->assertTrue(!empty($elements), 'Full pager found.'); // Verify elements and links to pages. // We expect to find 7 elements: links to '<< first' and '< previous' // pages, link to page 1, current page == 2, link to page 3 and links // to 'next >' and 'last >>' pages. - $this->assertClass($elements[0], 'pager-first', "Element for next page has .pager-first class."); + $this->assertClass($elements[0]->a->i, 'icon--go-first', "Element for first page has .icon--go-first class."); $this->assertTrue($elements[0]->a, "Link to first page found."); - $this->assertClass($elements[1], 'pager-previous', "Element for previous page has .pager-previous class."); + $this->assertClass($elements[1]->a->i, 'icon--go-previous', "Element for previous page has .icon--go-previous class."); $this->assertTrue($elements[1]->a, "Link to previous page found."); - $this->assertClass($elements[2], 'pager-item', "Element for page 1 has .pager-item class."); $this->assertTrue($elements[2]->a, "Link to page 1 found."); - $this->assertClass($elements[3], 'pager-current', 'Element for current page has .pager-current class.'); - $this->assertFalse(isset($elements[3]->a), 'Element for current page has no link.'); + $this->assertClass($elements[3], 'is-active', 'Element for current page has .is-active class.'); + $this->assertTrue(isset($elements[3]->a), 'Element for current page has link.'); - $this->assertClass($elements[4], 'pager-item', "Element for page 3 has .pager-item class."); $this->assertTrue($elements[4]->a, "Link to page 3 found."); - $this->assertClass($elements[5], 'pager-next', "Element for next page has .pager-next class."); + $this->assertClass($elements[5]->a->i, 'icon--go-next', "Element for next page has .icon--go-next class."); $this->assertTrue($elements[5]->a, "Link to next page found."); - $this->assertClass($elements[6], 'pager-last', "Element for last page has .pager-last class."); + $this->assertClass($elements[6]->a->i, 'icon--go-last', "Element for last page has .icon--go-last class."); $this->assertTrue($elements[6]->a, "Link to last page found."); // Test Mini Pager.