Skip to content

Commit

Permalink
create test cases #1301
Browse files Browse the repository at this point in the history
  • Loading branch information
shunguoy committed Apr 26, 2023
1 parent 9ba2144 commit 845c562
Show file tree
Hide file tree
Showing 3 changed files with 511 additions and 68 deletions.
18 changes: 13 additions & 5 deletions accessibility-checker-engine/src/v2/aria/ARIADefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2086,11 +2086,6 @@ export class ARIADefinitions {
validRoles: ["any"],
globalAriaAttributesValid: true
},
"summary": {
implicitRole: null,
validRoles: null,
globalAriaAttributesValid: true
},
"sup": {
implicitRole: ["superscript"],
validRoles: ["any"],
Expand Down Expand Up @@ -2504,6 +2499,19 @@ export class ARIADefinitions {
otherDisallowedAriaAttributes: ["aria-multiselectable"]
}
},
"summary": {
"first-summary-of-detail": {
implicitRole: null,
validRoles: null,
globalAriaAttributesValid: true,
otherAllowedAriaAttributes: ["aria-disabled", "aria-haspopup"]
},
"not-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 @@ -2559,6 +2568,15 @@ 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
Loading

0 comments on commit 845c562

Please sign in to comment.