Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(ngAria): don't attach roles to native controls #14145

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ngAria/aria.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
function shouldAttachRole(role, elem) {
// if element does not have role attribute
// AND element type is equal to role (if custom element has a type equaling shape) <-- remove?
// AND element is not INPUT
return !elem.attr('role') && (elem.attr('type') === role) && (elem[0].nodeName !== 'INPUT');
// AND element is not in nodeBlackList
return !elem.attr('role') && (elem.attr('type') === role) && !isNodeOneOf(elem, nodeBlackList);
}

function getShape(attr, elem) {
Expand Down
12 changes: 12 additions & 0 deletions test/ngAria/ariaSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,18 @@ describe('$aria', function() {
compileElement('<input type="range" ng-model="val"></div>');
expect(element.attr('role')).toBe(undefined);
});

they('should not add role to native $prop controls', {
select: '<select type="checkbox" ng-model="val"></select>',
textarea: '<textarea type="checkbox" ng-model="val"></textarea>',
button: '<button ng-click="doClick()"></button>',
summary: '<summary ng-click="doClick()"></summary>',
details: '<details ng-click="doClick()"></details>',
a: '<a ng-click="doClick()"></a>'
}, function(tmpl) {
var element = $compile(tmpl)(scope);
expect(element.attr('role')).toBeUndefined();
});
});

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