From 71dc6913238b597b4a44ab79417df117ecbfc93c Mon Sep 17 00:00:00 2001 From: Jeff Carey Date: Fri, 20 Jan 2017 13:13:54 -0800 Subject: [PATCH] feat(pagination): Added menu and menuitem roles (closes #6383) (#6386) feat(pagination): Added test --- src/pagination/pagination.js | 1 + src/pagination/test/pagination.spec.js | 9 +++++++++ template/pagination/pagination.html | 10 +++++----- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/pagination/pagination.js b/src/pagination/pagination.js index 4578624d6a..eaed65ca07 100644 --- a/src/pagination/pagination.js +++ b/src/pagination/pagination.js @@ -9,6 +9,7 @@ angular.module('ui.bootstrap.pagination', ['ui.bootstrap.paging', 'ui.bootstrap. pageLabel = angular.isDefined($attrs.pageLabel) ? function(idx) { return $scope.$parent.$eval($attrs.pageLabel, {$page: idx}); } : angular.identity; $scope.boundaryLinks = angular.isDefined($attrs.boundaryLinks) ? $scope.$parent.$eval($attrs.boundaryLinks) : uibPaginationConfig.boundaryLinks; $scope.directionLinks = angular.isDefined($attrs.directionLinks) ? $scope.$parent.$eval($attrs.directionLinks) : uibPaginationConfig.directionLinks; + $attrs.$set('role', 'menu'); uibPaging.create(this, $scope, $attrs); diff --git a/src/pagination/test/pagination.spec.js b/src/pagination/test/pagination.spec.js index 465a84c6db..bc4f6eee6e 100644 --- a/src/pagination/test/pagination.spec.js +++ b/src/pagination/test/pagination.spec.js @@ -54,6 +54,15 @@ describe('pagination directive', function() { expect(element.hasClass('pagination')).toBe(true); }); + it('has accessibility attributes', function() { + expect(element.attr('role')).toEqual('menu'); + + var li = element.find('li'); + for (var i = 0; i < li.length; i++) { + expect(li.eq(i).attr('role')).toEqual('menuitem'); + } + }); + it('exposes the controller to the template', function() { $templateCache.put('uib/template/pagination/pagination.html', '
{{pagination.randomText}}
'); var scope = $rootScope.$new(); diff --git a/template/pagination/pagination.html b/template/pagination/pagination.html index ab96bb978b..cf52a94e8d 100644 --- a/template/pagination/pagination.html +++ b/template/pagination/pagination.html @@ -1,5 +1,5 @@ -
  • {{::getText('first')}}
  • -
  • {{::getText('previous')}}
  • -
  • {{page.text}}
  • -
  • {{::getText('next')}}
  • -
  • {{::getText('last')}}
  • + + + + +