Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add allowEmpty option for aria-valid-attr-value #1154

Merged
merged 5 commits into from
Nov 14, 2018

Conversation

WilcoFiers
Copy link
Contributor

@WilcoFiers WilcoFiers commented Sep 20, 2018

Allow specifying per ARIA attribute which ones are allowed to be empty. Changes include:

  • aria-haspopup: Now allowed to be empty
  • aria-invalid: Now allowed to be empty
  • aria-current: Now allowed to be empty
  • aria-valuetext: No longer allowed to be empty

Closes #994

Reviewer checks

Required fields, to be filled out by PR reviewer(s)

  • Follows the commit message policy, appropriate for next version
  • Has documentation updated, a DU ticket, or requires no documentation change
  • Includes new tests, or was unnecessary
  • Code is reviewed for security by: Jey

@WilcoFiers WilcoFiers requested a review from a team as a code owner September 20, 2018 12:39
@WilcoFiers WilcoFiers changed the title feat: Add allowEmpty option for aria-valid-attr feat: Add allowEmpty option for aria-valid-attr-value Sep 20, 2018
jeeyyy
jeeyyy previously approved these changes Sep 20, 2018
Copy link
Contributor

@jeeyyy jeeyyy left a comment

Choose a reason for hiding this comment

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

Neat.

Copy link
Contributor

@dylanb dylanb left a comment

Choose a reason for hiding this comment

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

Looks to me like there were more changes than the ones listed, is that the case?

Also left a question about aria-label

},
'aria-label': {
type: 'string'
type: 'string',
allowEmpty: true
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have a test to make sure that an empty aria-label will not pass an input with aria-label=""?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

aria-label has always been allowed empty. See: https://github.com/dequelabs/axe-core/pull/1154/files#diff-0dbb83fa6e11da52031f948e3f85a3ecL105

Rules that require elements to have an accessible name don't allow empty or whitespace values to pass.

@@ -55,21 +59,24 @@ lookupTable.attributes = {
values: ['copy', 'move', 'reference', 'execute', 'popup', 'none']
},
'aria-errormessage': {
type: 'idref'
type: 'idref',
allowEmpty: true
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this new? If so, where are the tests for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In order to make this configurable per attribute I added this. This property is used in aria.validateAttrValue, which is where the tests for it are. All changes (see PR description) are also tested in integration tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is no current test to test that this passes when empty

dylanb
dylanb previously requested changes Oct 5, 2018
Copy link
Contributor

@dylanb dylanb left a comment

Choose a reason for hiding this comment

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

We need to add tests to make sure that the changes you made do not regress

},
'aria-labelledby': {
type: 'idrefs'
type: 'idrefs',
allowEmpty: true
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no current test to test the empty case for aria-labelledby - we should add one

@@ -113,10 +124,12 @@ lookupTable.attributes = {
values: ['horizontal', 'vertical']
},
'aria-owns': {
type: 'idrefs'
type: 'idrefs',
allowEmpty: true
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no current test for aria-owns to test that it is allowed to be empty

},
'aria-placeholder': {
type: 'string'
type: 'string',
allowEmpty: true
Copy link
Contributor

Choose a reason for hiding this comment

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

There are no tests for aria-placeholder

values: ['true', 'false', 'spelling', 'grammar']
},
'aria-keyshortcuts': {
type: 'string'
type: 'string',
allowEmpty: true
Copy link
Contributor

Choose a reason for hiding this comment

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

No tests for aria-keyshortcuts

},
'aria-expanded': {
type: 'nmtoken',
values: ['true', 'false', 'undefined']
},
'aria-flowto': {
type: 'idrefs'
type: 'idrefs',
allowEmpty: true
Copy link
Contributor

Choose a reason for hiding this comment

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

No current test for aria-flowto to test that it passes when empty

@@ -55,21 +59,24 @@ lookupTable.attributes = {
values: ['copy', 'move', 'reference', 'execute', 'popup', 'none']
},
'aria-errormessage': {
type: 'idref'
type: 'idref',
allowEmpty: true
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no current test to test that this passes when empty

values: ['page', 'step', 'location', 'date', 'time', 'true', 'false']
},
'aria-describedby': {
type: 'idrefs'
type: 'idrefs',
allowEmpty: true
Copy link
Contributor

Choose a reason for hiding this comment

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

No current test fo aria-describedby to show that it passes when empty

@@ -37,14 +38,17 @@ lookupTable.attributes = {
type: 'int'
},
'aria-controls': {
type: 'idrefs'
type: 'idrefs',
allowEmpty: true
Copy link
Contributor

Choose a reason for hiding this comment

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

No current test to show that this passes when empty

@WilcoFiers
Copy link
Contributor Author

@dylanb you were totally right. Actually found a bug with aria-errormessage. This should solve it.

@WilcoFiers WilcoFiers dismissed dylanb’s stale review October 11, 2018 09:32

Please review again

@@ -45,70 +45,3 @@ aria.validateAttr = function(att) {
'use strict';
return !!aria.lookupTable.attributes[att];
};

/**
Copy link
Contributor

Choose a reason for hiding this comment

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

I wish this file was moved in a separate commit so I could see if there were any changes to it side by side.... Lots of style changes mixed in here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how to do this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought maybe you could make the changes in the existing file in one commit and move/rename it in a separate commit. I don't think it's worth holding up this PR, just something to keep in mind moving forward.


afterEach(function() {
axe.commons.aria.lookupTable.attributes[
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we do this object assignment anywhere else? Maybe it makes sense to abstract into a utility that we can reuse?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not that I know of.

@marcysutton
Copy link
Contributor

@WilcoFiers are you going to add any more unit tests to this like Dylan mentioned, or is it covered enough by the integration tests?


function validateAttrValue() {
var idref = attr && doc.getElementById(attr);
function validateAttrValue(attr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is there a method here called validateAttrValue when there is also one in commons.aria? Should they be the same method, or at least have different names?

Copy link
Contributor Author

@WilcoFiers WilcoFiers Nov 9, 2018

Choose a reason for hiding this comment

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

I don't know. It was something you approved. Is it relevant to this PR?
c96f58c#diff-bbc5b3826882793926c0ad8f410725fe

Copy link
Contributor

@marcysutton marcysutton Nov 9, 2018

Choose a reason for hiding this comment

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

That PR doesn't reference the commons method, only the inline function. This PR has both.

@WilcoFiers WilcoFiers merged commit 89d18d0 into develop Nov 14, 2018
@WilcoFiers WilcoFiers deleted the aria-allowEmpty branch November 14, 2018 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants