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

fix(engine): update roles for summary and li elements per ARIA in HTML spec change #1413

Merged
merged 7 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ jspm_packages
.gz
.tar
accessibility-checker-engine/karma.conf.js
karma-accessibility-checker/package.json
35 changes: 25 additions & 10 deletions accessibility-checker-engine/src/v2/aria/ARIADefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1906,11 +1906,6 @@ export class ARIADefinitions {
validRoles: null,
globalAriaAttributesValid: true
},
"li": {
implicitRole: ["listitem"],
validRoles: ["menuitem", "menuitemcheckbox", "menuitemradio", "none", "option", "presentation", "radio", "separator", "tab", "treeitem"],
globalAriaAttributesValid: true
},
"link": {
implicitRole: null,
validRoles: null,
Expand Down Expand Up @@ -2086,11 +2081,6 @@ export class ARIADefinitions {
validRoles: ["any"],
globalAriaAttributesValid: true
},
"summary": {
implicitRole: ["button"],
validRoles: null,
globalAriaAttributesValid: true
},
"sup": {
implicitRole: ["superscript"],
validRoles: ["any"],
Expand Down Expand Up @@ -2476,6 +2466,18 @@ export class ARIADefinitions {
globalAriaAttributesValid: true
}
},
"li": {
"child-of-list-role": {
implicitRole: ['listitem'],
validRoles: null,
globalAriaAttributesValid: true
},
"no-child-of-list-role": {
implicitRole: ['listitem'],
validRoles: ["any"],
globalAriaAttributesValid: true
}
},
"section": {
"with-name": {
implicitRole: ["region"],
Expand Down Expand Up @@ -2504,6 +2506,19 @@ export class ARIADefinitions {
otherDisallowedAriaAttributes: ["aria-multiselectable"]
}
},
"summary": {
"first-summary-of-detail": {
implicitRole: null,
validRoles: null,
globalAriaAttributesValid: true,
otherAllowedAriaAttributes: ["aria-disabled", "aria-haspopup"]
},
"no-first-summary-of-detail": {
implicitRole: null,
validRoles: ["any"],
globalAriaAttributesValid: true
}
},
"tbody": {
"des-table": {
implicitRole: ["rowgroup"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { DOMWalker } from "../../../dom/DOMWalker";
import { VisUtil } from "../../../dom/VisUtil";
import { FragmentUtil } from "./fragment";
import { getDefinedStyles } from "../../../../v4/util/CSSUtil";
import { DOMUtil } from "../../../dom/DOMUtil";

export class RPTUtil {

Expand Down Expand Up @@ -376,7 +377,15 @@ export class RPTUtil {
"video": function (element) {
return element.hasAttribute("controls");
},
"summary": true
"summary": function (element) {
// first summary child of a details element is automatically focusable
return element.parentElement && element.parentElement.nodeName.toLowerCase() === 'details'
&& DOMUtil.sameNode([...element.parentElement.children].filter(elem=>elem.nodeName.toLowerCase() === 'summary')[0], element);
},
"details": function (element) {
//details element without a direct summary child is automatically focusable
return element.children && [...element.children].filter(elem=>elem.nodeName.toLowerCase() === 'summary').length === 0;
}
}

public static wordCount(str) : number {
Expand Down Expand Up @@ -2543,14 +2552,21 @@ export class RPTUtil {
RPTUtil.attributeNonEmpty(ruleContext, "list") ? tagProperty = specialTagProperties["text-with-list"] : tagProperty = specialTagProperties["text-no-list"];
}
break;
case "li":
specialTagProperties = ARIADefinitions.documentConformanceRequirementSpecialTags["li"];
if (ruleContext.parentElement && RPTUtil.hasRoleInSemantics(ruleContext.parentElement, "list"))
tagProperty = specialTagProperties["child-of-list-role"];
else
tagProperty = specialTagProperties["no-child-of-list-role"];
break;
case "section":
name = ARIAMapper.computeName(ruleContext);
if (name && name.trim().length > 0) {
tagProperty = specialTagProperties["with-name"];
} else {
tagProperty = specialTagProperties["without-name"];
}
break;
break;
case "select":
specialTagProperties = ARIADefinitions.documentConformanceRequirementSpecialTags["select"];
if (ruleContext.hasAttribute("multiple") ||
Expand All @@ -2559,6 +2575,14 @@ export class RPTUtil {
else
tagProperty = specialTagProperties["no-multiple-attr-size-gt1"];
break;
case "summary":
specialTagProperties = ARIADefinitions.documentConformanceRequirementSpecialTags["summary"];
if (ruleContext.parentElement && ruleContext.parentElement.nodeName.toLowerCase() === 'details'
&& DOMUtil.sameNode([...ruleContext.parentElement.children].filter(elem=>elem.nodeName.toLowerCase() === 'summary')[0], ruleContext))
tagProperty = specialTagProperties["first-summary-of-detail"];
else
tagProperty = specialTagProperties["no-first-summary-of-detail"];
break;
case "tbody":
case "td":
case "tr":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,16 +572,16 @@ <h1 id="contents1">Button 1 Label</h1>
"ruleId": "aria_semantics_role",
"value": [
"INFORMATION",
"PASS"
"FAIL"
],
"path": {
"dom": "/html[1]/body[1]/ol[1]/li[1]",
"aria": "/document[1]/document[1]/list[2]/listitem[1]"
},
"reasonId": "Pass_0",
"message": "Rule Passed",
"reasonId": "Fail_1",
"message": "The ARIA role 'tab, separator' is not valid for the element <li>",
"messageArgs": [
"listitem, tab, separator",
"tab, separator",
"li"
],
"apiArgs": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1293,14 +1293,14 @@ <h2 role="heading" aria-label="h2_El" id="h2_El2" aria-level="1"> Heading level
"ruleId": "aria_semantics_role",
"value": [
"INFORMATION",
"FAIL"
"PASS"
],
"path": {
"dom": "/html[1]/body[1]/div[1]/li[1]",
"aria": "/document[1]/generic[1]/region[1]/slider[9]"
},
"reasonId": "Fail_1",
"message": "The ARIA role 'slider' is not valid for the element <li>",
"reasonId": "Pass_0",
"message": "Rule Passed",
"messageArgs": [
"slider",
"li"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
],
"path": {
"dom": "/html[1]/body[1]/details[1]/summary[1]",
"aria": "/document[1]/generic[1]/group[1]/button[1]"
"aria": "/document[1]/generic[1]/group[1]"
},
"reasonId": "Fail_1",
"message": "Element \"summary\" should not be focusable within the subtree of an element with an 'aria-hidden' attribute with value 'true'",
Expand Down
Loading