Skip to content

Commit cb9498a

Browse files
committed
fix(ngAria): don't attach roles to native controls
don't add roles to (textarea, button, select, input) fix angular#14076
1 parent 32feb2b commit cb9498a

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/ngAria/aria.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
221221
function shouldAttachRole(role, elem) {
222222
// if element does not have role attribute
223223
// AND element type is equal to role (if custom element has a type equaling shape) <-- remove?
224-
// AND element is not INPUT
225-
return !elem.attr('role') && (elem.attr('type') === role) && (elem[0].nodeName !== 'INPUT');
224+
// AND element is not in nodeBlackList
225+
return !elem.attr('role') && (elem.attr('type') === role) && !isNodeOneOf(elem, nodeBlackList);
226226
}
227227

228228
function getShape(attr, elem) {

test/ngAria/ariaSpec.js

+16
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,22 @@ describe('$aria', function() {
272272
compileElement('<input type="range" ng-model="val"></div>');
273273
expect(element.attr('role')).toBe(undefined);
274274
});
275+
276+
it('should not add a role to a native select', function() {
277+
compileElement('<select></select>');
278+
expect(element.attr('role')).toBe(undefined);
279+
});
280+
281+
it('should not add a role to a native textarea', function() {
282+
compileElement('<textarea></textarea>');
283+
expect(element.attr('role')).toBe(undefined);
284+
});
285+
286+
it('should not add a role to a native textarea', function() {
287+
compileElement('<button></button>');
288+
expect(element.attr('role')).toBe(undefined);
289+
});
290+
275291
});
276292

277293
describe('aria-checked when disabled', function() {

0 commit comments

Comments
 (0)