Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
fix(list): support aria-label for primary action
Browse files Browse the repository at this point in the history
Closes #2773
  • Loading branch information
Marcy Sutton committed May 7, 2015
1 parent 05788d2 commit e9324a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/list/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ function mdListItemDirective($mdAria, $mdConstant, $timeout) {
container = angular.element('<md-button class="md-no-style"><div class="md-list-item-inner"></div></md-button>');
container[0].setAttribute('ng-click', tEl[0].getAttribute('ng-click'));
tEl[0].removeAttribute('ng-click');

if (tEl[0].getAttribute('aria-label')) {
container[0].setAttribute('aria-label', tEl[0].getAttribute('aria-label'));
tEl[0].removeAttribute('aria-label');
}
container.children().eq(0).append(tEl.contents());
}

Expand Down
7 changes: 7 additions & 0 deletions src/components/list/list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ describe('mdListItem directive', function() {
expect(firstChild.childNodes[0].childNodes[0].nodeName).toBe('P');
});

it('moves aria-label to primary action', function() {
var listItem = setup('<md-list-item ng-click="sayHello()" aria-label="Hello"></md-list-item>');
var listItemChildren = listItem.children();
expect(listItemChildren[0].nodeName).toBe('MD-BUTTON');
expect(listItemChildren.attr('aria-label')).toBe('Hello');
});

it('moves md-secondary items outside of the button', function() {
var listItem = setup('<md-list-item ng-click="sayHello()"><p>Hello World</p><md-icon class="md-secondary" ng-click="goWild()"></md-icon></md-list-item>');
var firstChild = listItem.children()[0];
Expand Down

0 comments on commit e9324a9

Please sign in to comment.