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

fix(ngAria): Prevent aria-invalid from being added to hidden inputs #15113

Closed
wants to merge 2 commits 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
2 changes: 1 addition & 1 deletion src/ngAria/aria.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
.directive('ngModel', ['$aria', function($aria) {

function shouldAttachAttr(attr, normalizedAttr, elem, allowBlacklistEls) {
return $aria.config(normalizedAttr) && !elem.attr(attr) && (allowBlacklistEls || !isNodeOneOf(elem, nodeBlackList));
return $aria.config(normalizedAttr) && !elem.attr(attr) && (allowBlacklistEls || !isNodeOneOf(elem, nodeBlackList)) && elem.attr('type') !== 'hidden';
}

function shouldAttachRole(role, elem) {
Expand Down
5 changes: 5 additions & 0 deletions test/ngAria/ariaSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,11 @@ describe('$aria', function() {
scope.$apply('txtInput=\'LTten\'');
expect(element.attr('aria-invalid')).toBe('userSetValue');
});

it('should not attach if input is type="hidden"', function() {
compileElement('<input type="hidden" ng-model="txtInput">');
expect(element.attr('aria-invalid')).toBeUndefined();
});
});

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