-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
new_audit(axe): input-button-name, role-img-alt, select-name #12700
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6e55d70
new_audit(axe): add input-button-name, role-img-alt, select-name
paulirish 061381b
Merge branch 'axeaudittest' into new-three-axe-audits
paulirish 4e039f8
add to config
paulirish 1a16e8d
tests: add test to confirm all audits in config are in use by a category
paulirish b05d3b3
Merge branch 'axeaudittest' into new-three-axe-audits
paulirish 06052cc
snap
paulirish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* @license Copyright 2021 The Lighthouse Authors. All Rights Reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
'use strict'; | ||
|
||
/** | ||
* @fileoverview Ensures input buttons have discernible text. | ||
* See base class in axe-audit.js for audit() implementation. | ||
* | ||
* See PR where input-button-name was split out from button-name: | ||
* @url https://github.com/dequelabs/axe-core/pull/1615 | ||
*/ | ||
|
||
const AxeAudit = require('./axe-audit.js'); | ||
const i18n = require('../../lib/i18n/i18n.js'); | ||
|
||
const UIStrings = { | ||
/** Title of an accesibility audit that evaluates if all input button elements have names accessible to screen readers. This title is descriptive of the successful state and is shown to users when no user action is required. */ | ||
title: 'Input buttons have an accessible name', | ||
/** Title of an accesibility audit that evaluates if all input button elements have names accessible to screen readers. This title is descriptive of the failing state and is shown to users when there is a failure that needs to be addressed. */ | ||
failureTitle: 'Input buttons do not have an accessible name', | ||
/** Description of a Lighthouse audit that tells the user *why* they should try to pass. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */ | ||
description: 'When an input button doesn\'t have an accessible name, screen readers announce ' + | ||
'it as "button", making it unusable for users who rely on screen readers. ' + | ||
'[Learn more](https://dequeuniversity.com/rules/axe/4.1/input-button-name?application=lighthouse).', | ||
}; | ||
|
||
|
||
const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings); | ||
|
||
class InputButtonName extends AxeAudit { | ||
/** | ||
* @return {LH.Audit.Meta} | ||
*/ | ||
static get meta() { | ||
return { | ||
id: 'input-button-name', | ||
title: str_(UIStrings.title), | ||
failureTitle: str_(UIStrings.failureTitle), | ||
description: str_(UIStrings.description), | ||
requiredArtifacts: ['Accessibility'], | ||
}; | ||
} | ||
} | ||
|
||
module.exports = InputButtonName; | ||
module.exports.UIStrings = UIStrings; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,47 @@ | ||||
/** | ||||
* @license Copyright 2021 The Lighthouse Authors. All Rights Reserved. | ||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||||
*/ | ||||
'use strict'; | ||||
|
||||
/** | ||||
* @fileoverview Ensures elements with [role="img"] have discernible text. | ||||
* See base class in axe-audit.js for audit() implementation. | ||||
* | ||||
* See PR where role-img-alt-name was split out from image-alt: | ||||
* @url https://github.com/dequelabs/axe-core/pull/1586 | ||||
*/ | ||||
|
||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
const AxeAudit = require('./axe-audit.js'); | ||||
const i18n = require('../../lib/i18n/i18n.js'); | ||||
|
||||
const UIStrings = { | ||||
/** Title of an accesibility audit that evaluates if all role=img elements are given names. This title is descriptive of the successful state and is shown to users when no user action is required. */ | ||||
title: 'Elements with `[role=img]` have an accessible name', | ||||
/** Title of an accesibility audit that evaluates if all role=img elements are given names. This title is descriptive of the failing state and is shown to users when there is a failure that needs to be addressed. */ | ||||
failureTitle: 'Elements with `[role=img]` do not have an accessible name', | ||||
/** Description of a Lighthouse audit that tells the user *why* they should have accessible names for meter elements. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */ | ||||
description: 'When an element doesn\'t have an accessible name, screen readers announce it with a generic name, making it unusable for users who rely on screen readers. [Learn more](https://dequeuniversity.com/rules/axe/4.1/role-img-alt?application=lighthouse).', | ||||
}; | ||||
|
||||
const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings); | ||||
|
||||
class RoleImgAlt extends AxeAudit { | ||||
/** | ||||
* @return {LH.Audit.Meta} | ||||
*/ | ||||
static get meta() { | ||||
return { | ||||
id: 'role-img-alt', | ||||
title: str_(UIStrings.title), | ||||
failureTitle: str_(UIStrings.failureTitle), | ||||
description: str_(UIStrings.description), | ||||
requiredArtifacts: ['Accessibility'], | ||||
}; | ||||
} | ||||
} | ||||
|
||||
module.exports = RoleImgAlt; | ||||
module.exports.UIStrings = UIStrings; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,48 @@ | ||||||
/** | ||||||
* @license Copyright 2021 The Lighthouse Authors. All Rights Reserved. | ||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||||||
*/ | ||||||
'use strict'; | ||||||
|
||||||
/** | ||||||
* @fileoverview Ensures every select element has a label. | ||||||
* See base class in axe-audit.js for audit() implementation. | ||||||
* | ||||||
* See PR where select-name was split out from label: | ||||||
* @url https://github.com/dequelabs/axe-core/pull/2448 | ||||||
*/ | ||||||
|
||||||
const AxeAudit = require('./axe-audit.js'); | ||||||
const i18n = require('../../lib/i18n/i18n.js'); | ||||||
|
||||||
const UIStrings = { | ||||||
/** Title of an accesibility audit that evaluates if all select elements have corresponding label elements. This title is descriptive of the successful state and is shown to users when no user action is required. */ | ||||||
title: 'Select elements have associated labels', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
so translators dont touch it |
||||||
/** Title of an accesibility audit that evaluates if all select elements have corresponding label elements. This title is descriptive of the failing state and is shown to users when there is a failure that needs to be addressed. */ | ||||||
failureTitle: 'Select elements do not have associated labels', | ||||||
/** Description of a Lighthouse audit that tells the user *why* they should try to pass. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */ | ||||||
description: 'Labels ensure that dropdowns are announced properly by assistive ' + | ||||||
'technologies, like screen readers. [Learn ' + | ||||||
'more](https://dequeuniversity.com/rules/axe/4.1/select-name?application=lighthouse).', | ||||||
}; | ||||||
|
||||||
const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings); | ||||||
|
||||||
class SelectName extends AxeAudit { | ||||||
/** | ||||||
* @return {LH.Audit.Meta} | ||||||
*/ | ||||||
static get meta() { | ||||||
return { | ||||||
id: 'select-name', | ||||||
title: str_(UIStrings.title), | ||||||
failureTitle: str_(UIStrings.failureTitle), | ||||||
description: str_(UIStrings.description), | ||||||
requiredArtifacts: ['Accessibility'], | ||||||
}; | ||||||
} | ||||||
} | ||||||
|
||||||
module.exports = SelectName; | ||||||
module.exports.UIStrings = UIStrings; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protip: we automatically ignore max-len for lines with URLs. so you dont have to do the string concat bs (which is liable to generating spacing issues)