-
Notifications
You must be signed in to change notification settings - Fork 763
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 aria-structure-name rule #2431
Closed
Closed
Changes from all commits
Commits
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,17 @@ | ||
{ | ||
"id": "name-author-contents", | ||
"selector": "[role=\"treeitem\"]", | ||
"tags": [], | ||
"metadata": { | ||
"description": "Ensures elements with ARIA roles that require an accessible name have one from author or contents.", | ||
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. I would avoid talking about author or content here for the same reasons as stated above. |
||
"help": "Required accessible name must be present (author or contents)" | ||
}, | ||
"all": [], | ||
"any": [ | ||
"aria-label", | ||
"aria-labelledby", | ||
"has-visible-text", | ||
"non-empty-title" | ||
], | ||
"none": [] | ||
} |
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,12 @@ | ||
{ | ||
"id": "name-author", | ||
"selector": "[role=\"tree\"]", | ||
"tags": [], | ||
"metadata": { | ||
"description": "Ensures elements with ARIA roles that require an accessible name have one from author.", | ||
"help": "Required accessible name must be present (author)" | ||
}, | ||
"all": [], | ||
"any": ["aria-label", "aria-labelledby", "non-empty-title"], | ||
"none": [] | ||
} |
21 changes: 21 additions & 0 deletions
21
test/integration/rules/name-author-contents/name-author-contents.html
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,21 @@ | ||
<div id="labeldiv">Some label</div> | ||
<div id="emptydiv"></div> | ||
|
||
<div role="treeitem" id="treeitem-empty"></div> | ||
<div role="treeitem" id="treeitem-text">Name</div> | ||
<div role="treeitem" id="treeitem-al" aria-label="Name"></div> | ||
<div role="treeitem" id="treeitem-alempty" aria-label=""></div> | ||
<div role="treeitem" id="treeitem-alb" aria-labelledby="labeldiv"></div> | ||
<div | ||
role="treeitem" | ||
id="treeitem-albmissing" | ||
aria-labelledby="nonexistent" | ||
></div> | ||
<div role="treeitem" id="treeitem-albempty" aria-labelledby="emptydiv"></div> | ||
<div role="treeitem" id="treeitem-combo" aria-label="Aria Name">Name</div> | ||
<div role="treeitem" id="treeitem-title" title="Title"></div> | ||
|
||
<ul role="tree"> | ||
<li role="treeitem" id="treeitem-li-named">named</li> | ||
<li role="treeitem" id="treeitem-li-unnamed"></li> | ||
</ul> |
19 changes: 19 additions & 0 deletions
19
test/integration/rules/name-author-contents/name-author-contents.json
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,19 @@ | ||
{ | ||
"description": "name-author-contents test", | ||
"rule": "name-author-contents", | ||
"violations": [ | ||
["#treeitem-empty"], | ||
["#treeitem-alempty"], | ||
["#treeitem-albmissing"], | ||
["#treeitem-albempty"], | ||
["#treeitem-li-unnamed"] | ||
], | ||
"passes": [ | ||
["#treeitem-text"], | ||
["#treeitem-al"], | ||
["#treeitem-alb"], | ||
["#treeitem-combo"], | ||
["#treeitem-title"], | ||
["#treeitem-li-named"] | ||
] | ||
} |
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,15 @@ | ||
<div id="labeldiv">Some label</div> | ||
<div id="emptydiv"></div> | ||
|
||
<div role="tree" id="tree-empty"></div> | ||
<div role="tree" id="tree-text">Name</div> | ||
<div role="tree" id="tree-al" aria-label="Name"></div> | ||
<div role="tree" id="tree-alempty" aria-label=""></div> | ||
<div role="tree" id="tree-alb" aria-labelledby="labeldiv"></div> | ||
<div role="tree" id="tree-albmissing" aria-labelledby="nonexistent"></div> | ||
<div role="tree" id="tree-albempty" aria-labelledby="emptydiv"></div> | ||
<div role="tree" id="tree-combo" aria-label="Aria Name">Name</div> | ||
<div role="tree" id="tree-title" title="Title"></div> | ||
|
||
<ul role="tree" id="tree-ul-unnamed"></ul> | ||
<ul role="tree" id="tree-ul-named" aria-label="named"></ul> |
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,19 @@ | ||
{ | ||
"description": "name-author test", | ||
"rule": "name-author", | ||
"violations": [ | ||
["#tree-empty"], | ||
["#tree-alempty"], | ||
["#tree-albmissing"], | ||
["#tree-albempty"], | ||
["#tree-ul-unnamed"], | ||
["#tree-text"] | ||
], | ||
"passes": [ | ||
["#tree-al"], | ||
["#tree-alb"], | ||
["#tree-combo"], | ||
["#tree-title"], | ||
["#tree-ul-named"] | ||
] | ||
} |
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.
The rule name is a bit vague. Ideally it would tell me what the rule is checking, like
button-name
orimage-alt
.name-author-contents
does that, but I may not understand what name from author or contents means.Maybe something like
role-required-name
? I'm not sure how to appropriately differentiate between having visible text or not.