Skip to content

Commit b45c43c

Browse files
committed
fix(ngAria): remove tabindex from radio buttons
Closes angular#12492
1 parent 5af8540 commit b45c43c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/ngAria/aria.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ var ngAriaModule = angular.module('ngAria', ['ng']).
5353
provider('$aria', $AriaProvider);
5454

5555
/**
56-
* Internal Utilities
56+
* Internal Utilities
5757
*/
5858
var nodeBlackList = ['BUTTON', 'A', 'INPUT', 'TEXTAREA', 'SELECT', 'DETAILS', 'SUMMARY'];
5959

60-
var isNodeOneOf = function (elem, nodeTypeArray) {
60+
var isNodeOneOf = function(elem, nodeTypeArray) {
6161
if (nodeTypeArray.indexOf(elem[0].nodeName) !== -1) {
6262
return true;
6363
}
64-
}
64+
};
6565
/**
6666
* @ngdoc provider
6767
* @name $ariaProvider
@@ -235,7 +235,8 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
235235
}
236236
},
237237
post: function(scope, elem, attr, ngModel) {
238-
var needsTabIndex = shouldAttachAttr('tabindex', 'tabindex', elem);
238+
var needsTabIndex = shouldAttachAttr('tabindex', 'tabindex', elem)
239+
&& !isNodeOneOf(elem, nodeBlackList);
239240

240241
function ngAriaWatchModelValue() {
241242
return ngModel.$modelValue;

test/ngAria/ariaSpec.js

+7
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,13 @@ describe('$aria', function() {
628628
expectAriaAttrOnEachElement(element, 'tabindex', undefined);
629629
});
630630

631+
it('should not attach to native controls via ngmodel', function() {
632+
scope.$apply('val = null');
633+
compileElement('<input type="radio" name="value" value="1" ng-model="val">');
634+
635+
expect(element.attr('tabindex')).toBeUndefined();
636+
});
637+
631638
it('should not attach to random ng-model elements', function() {
632639
compileElement('<div ng-model="val"></div>');
633640
expect(element.attr('tabindex')).toBeUndefined();

0 commit comments

Comments
 (0)