Skip to content
This repository has been 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

Conversation

edclements
Copy link

This fixes a error found using the Google Accessibility Developer Tools audit.
Input fields of type hidden shouldn't have aria attributes.
https://www.w3.org/TR/html-aria/#allowed-aria-roles-states-and-properties-1

This fixes a error found using the Google Accessibility Developer Tools audit.
Input fields of type hidden shouldn't have aria attributes.
https://www.w3.org/TR/html-aria/#allowed-aria-roles-states-and-properties-1
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

1 similar comment
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@edclements
Copy link
Author

I signed it!

@gkalpak
Copy link
Member

gkalpak commented Sep 9, 2016

Input fields of type hidden shouldn't have aria attributes.

We are already excluding all input fields as part of the !isNodeOneOf(...) check.
I am going to close this, since everything seems to be working as expected, but feel free to continue the discussion below.

BTW, the section of the spec you have linked to does not refer to what your PR is about. It refers to elements with a hidden attribute (e.g. <div hidden>).

@gkalpak gkalpak closed this Sep 9, 2016
@edclements
Copy link
Author

The isNodeOneOf check doesn't apply for aria-invalid as allowBlacklistEls is being passed in as true. The test I wrote will fail without the code change.

The relevant row in the spec reads as follows:
input type = hidden No corresponding role No role or aria* attributes

@gkalpak
Copy link
Member

gkalpak commented Sep 10, 2016

Sorry, I read this incorrectly. I am reopening and will review soon.
In the meantime, make sure you have signed the CLA (or we won't be able to merge this).

@gkalpak gkalpak reopened this Sep 10, 2016
@@ -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 hidden', function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: It would be more clear to say: ...if input is type="hidden"

@gkalpak
Copy link
Member

gkalpak commented Sep 10, 2016

LGTM (but we still need a signed CLA to merge).
@edclements, feel free to ping me when/if you have sorted it out.

@edclements
Copy link
Author

Thanks for taking a look @gkalpak. I signed the CLA as a company: BookingBug.

@gkalpak
Copy link
Member

gkalpak commented Sep 12, 2016

@IgorMinar (or someone else), can you verify the CLA?

@IgorMinar
Copy link
Contributor

@gkalpak BookingBug is good! 👍

@gkalpak
Copy link
Member

gkalpak commented Oct 14, 2016

Actually, I am going to mark this as a breaking change and merge it into 1.6 only. It might break tests (unlikely but possible).

@gkalpak gkalpak modified the milestones: 1.7.0, Purgatory Oct 20, 2016
@gkalpak
Copy link
Member

gkalpak commented Oct 20, 2016

We decided not to add more breaking changes into 1.6 at this point, so moving this to 1.7.

@Narretz
Copy link
Contributor

Narretz commented Jan 30, 2017

LGTM2 and it can be merged because master is on 1.7

@gkalpak
Copy link
Member

gkalpak commented Jan 31, 2017

Actually, I just realized that -while the the spec only mentions input[type=hidden] - this PR affects all [type=hidden] elements. @edclements can you update it so that it ignores input element's only and add a corresponding test?

@Narretz
Copy link
Contributor

Narretz commented Nov 30, 2017

@edclements it's been a while but are you still interested / available to make the changes required for this PR? See #15113 (comment)

@Narretz Narretz closed this Nov 30, 2017
@Narretz Narretz reopened this Nov 30, 2017
Narretz added a commit to Narretz/angular.js that referenced this pull request Dec 8, 2017
This fixes a error found by @edclements  using the Google Accessibility Developer Tools audit.
Input fields of type hidden shouldn't have aria attributes.
https://www.w3.org/TR/html-aria/#allowed-aria-roles-states-and-properties-1

Closes angular#15113
@Narretz
Copy link
Contributor

Narretz commented Dec 8, 2017

I've created an updated PR here: #16367 No need to update this PR anymore. Thanks @edclements for getting this on the road.

@Narretz Narretz closed this Dec 8, 2017
Narretz added a commit that referenced this pull request Dec 11, 2017
This fixes a error found by @edclements  using the Google Accessibility Developer Tools audit.
Input fields of type hidden shouldn't have aria attributes.
https://www.w3.org/TR/html-aria/#allowed-aria-roles-states-and-properties-1

Closes #15113 
Closes #16367

BREAKING CHANGE:

ngAria no longer sets aria-* attributes on input[type="hidden"] with ngModel.
This can affect apps that test for the presence of aria attributes on hidden inputs.
To migrate, remove these assertions.
In actual apps, this should not have a user-facing effect, as the previous behavior 
was incorrect, and the new behavior is correct for accessibility.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants