Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(list): restore ui-sref and href support on md-list-item
Browse files Browse the repository at this point in the history
closes #2131
  • Loading branch information
rschmukler committed Oct 15, 2015
1 parent f966d0f commit f8a8b3c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/list/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ function mdListItemDirective($mdAria, $mdConstant, $mdUtil, $timeout) {

tEl[0].setAttribute('role', 'listitem');

if (!tAttrs.ngClick) {
if (tAttrs.ngClick || tAttrs.ngHref || tAttrs.href || tAttrs.uiSref || tAttrs.ngAttrUiSref) {

This comment has been minimized.

Copy link
@ThomasBurleson

ThomasBurleson Oct 15, 2015

Contributor

👍

wrapIn('button');
} else {
for (var i = 0, type; type = proxiedTypes[i]; ++i) {
if (proxyElement = tEl[0].querySelector(type)) {
hasProxiedElement = true;
Expand All @@ -105,8 +107,6 @@ function mdListItemDirective($mdAria, $mdConstant, $mdUtil, $timeout) {
} else if (!tEl[0].querySelector('md-button:not(.md-secondary):not(.md-exclude)')) {
tEl.addClass('md-no-proxy');
}
} else {
wrapIn('button');
}
setupToggleAria();

Expand Down Expand Up @@ -134,7 +134,8 @@ function mdListItemDirective($mdAria, $mdConstant, $mdUtil, $timeout) {
tEl.addClass('md-proxy-focus');
} else {
container = angular.element('<md-button class="md-no-style"><div class="md-list-item-inner"></div></md-button>');
var copiedAttrs = ['ng-click', 'aria-label', 'ng-disabled'];
var copiedAttrs = ['ng-click', 'aria-label', 'ng-disabled',
'ui-sref', 'href', 'ng-href', 'ng-attr-ui-sref'];
angular.forEach(copiedAttrs, function(attr) {
if (tEl[0].hasAttribute(attr)) {
container[0].setAttribute(attr, tEl[0].getAttribute(attr));
Expand Down
14 changes: 14 additions & 0 deletions src/components/list/list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ describe('mdListItem directive', function() {
expect(firstChild.childNodes[0].childNodes[0].nodeName).toBe('P');
});

it('creates buttons when used with ui-sref', function() {
var listItem = setup('<md-list-item ui-sref="somestate"><p>Hello world</p></md-list-item>');
var firstChild = listItem.children()[0];
expect(firstChild.nodeName).toBe('MD-BUTTON');
expect(firstChild.hasAttribute('ui-sref')).toBeTruthy();
});

it('creates buttons when used with href', function() {
var listItem = setup('<md-list-item href="/somewhere"><p>Hello world</p></md-list-item>');
var firstChild = listItem.children()[0];
expect(firstChild.nodeName).toBe('MD-BUTTON');
expect(firstChild.hasAttribute('href')).toBeTruthy();
});

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();
Expand Down

1 comment on commit f8a8b3c

@hodeyp
Copy link

@hodeyp hodeyp commented on f8a8b3c Oct 16, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!!

Please sign in to comment.