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

Commit

Permalink
fix(list): correctly proxy ng-disabled attrs
Browse files Browse the repository at this point in the history
closes #2718
  • Loading branch information
rschmukler committed May 20, 2015
1 parent fc90fd3 commit a25bc0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
15 changes: 7 additions & 8 deletions src/components/list/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ function mdListItemDirective($mdAria, $mdConstant, $timeout) {
}
}


function wrapIn(type) {
var container;
if (type == 'div') {
Expand All @@ -119,13 +118,13 @@ function mdListItemDirective($mdAria, $mdConstant, $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>');
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');
}
var copiedAttrs = ['ng-click', 'aria-label', 'ng-disabled'];
angular.forEach(copiedAttrs, function(attr) {
if (tEl[0].hasAttribute(attr)) {
container[0].setAttribute(attr, tEl[0].getAttribute(attr));
tEl[0].removeAttribute(attr);
}
});
container.children().eq(0).append(tEl.contents());
}

Expand Down
3 changes: 2 additions & 1 deletion src/components/list/list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ describe('mdListItem directive', function() {


it('creates buttons when used with ng-click', function() {
var listItem = setup('<md-list-item ng-click="sayHello()"><p>Hello world</p></md-list-item>');
var listItem = setup('<md-list-item ng-click="sayHello()" ng-disabled="true"><p>Hello world</p></md-list-item>');
var firstChild = listItem.children()[0];
expect(firstChild.nodeName).toBe('MD-BUTTON');
expect(firstChild.hasAttribute('ng-disabled')).toBeTruthy();
expect(firstChild.childNodes[0].nodeName).toBe('DIV');
expect(firstChild.childNodes[0].childNodes[0].nodeName).toBe('P');
});
Expand Down

0 comments on commit a25bc0e

Please sign in to comment.