Skip to content

Commit

Permalink
fix(ngAria): remove tabindex from radio buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
marcysutton committed Oct 14, 2015
1 parent 5af8540 commit b45c43c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/ngAria/aria.js
Expand Up @@ -53,15 +53,15 @@ var ngAriaModule = angular.module('ngAria', ['ng']).
provider('$aria', $AriaProvider);

/**
* Internal Utilities
* Internal Utilities
*/
var nodeBlackList = ['BUTTON', 'A', 'INPUT', 'TEXTAREA', 'SELECT', 'DETAILS', 'SUMMARY'];

var isNodeOneOf = function (elem, nodeTypeArray) {
var isNodeOneOf = function(elem, nodeTypeArray) {
if (nodeTypeArray.indexOf(elem[0].nodeName) !== -1) {
return true;
}
}
};
/**
* @ngdoc provider
* @name $ariaProvider
Expand Down Expand Up @@ -235,7 +235,8 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
}
},
post: function(scope, elem, attr, ngModel) {
var needsTabIndex = shouldAttachAttr('tabindex', 'tabindex', elem);
var needsTabIndex = shouldAttachAttr('tabindex', 'tabindex', elem)
&& !isNodeOneOf(elem, nodeBlackList);

function ngAriaWatchModelValue() {
return ngModel.$modelValue;
Expand Down
7 changes: 7 additions & 0 deletions test/ngAria/ariaSpec.js
Expand Up @@ -628,6 +628,13 @@ describe('$aria', function() {
expectAriaAttrOnEachElement(element, 'tabindex', undefined);
});

it('should not attach to native controls via ngmodel', function() {
scope.$apply('val = null');
compileElement('<input type="radio" name="value" value="1" ng-model="val">');

expect(element.attr('tabindex')).toBeUndefined();
});

it('should not attach to random ng-model elements', function() {
compileElement('<div ng-model="val"></div>');
expect(element.attr('tabindex')).toBeUndefined();
Expand Down

0 comments on commit b45c43c

Please sign in to comment.