Skip to content

Commit

Permalink
remove deprecated aria roles and attributes. #696
Browse files Browse the repository at this point in the history
  • Loading branch information
shunguoy committed Feb 28, 2022
1 parent 36615c4 commit c981d73
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 90 deletions.
50 changes: 34 additions & 16 deletions accessibility-checker-engine/src/v2/aria/ARIADefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
export interface IDocumentConformanceRequirement {
implicitRole: string[],
validRoles: string[],
globalAriaAttributesValid: boolean
globalAriaAttributesValid: boolean,
allowedOtherAriaAttributes?: string[],
disallowedOtherAriaAttributes?: string[]
}

export class ARIADefinitions {
Expand Down Expand Up @@ -1606,18 +1608,19 @@ export class ARIADefinitions {
globalAriaAttributesValid: true
},
"body": {
implicitRole: ["document"],
implicitRole: null,
validRoles: null,
globalAriaAttributesValid: true
},
"br": {
implicitRole: null,
validRoles: ["none", "presentation"],
globalAriaAttributesValid: true
globalAriaAttributesValid: false,
allowedOtherAriaAttributes: ["aria-hidden"]
},
"button": {
implicitRole: ["button"],
validRoles: ["checkbox", "link", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "radio", "switch", "tab"],
validRoles: ["checkbox", "combobox", "link", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "radio", "switch", "tab"],
globalAriaAttributesValid: true
},
"canvas": {
Expand Down Expand Up @@ -1725,6 +1728,11 @@ export class ARIADefinitions {
validRoles: null,
globalAriaAttributesValid: false
},
"hgroup": {
implicitRole: null,
validRoles: ["any"],
globalAriaAttributesValid: true
},
"h1": {
implicitRole: ["heading"],
validRoles: ["doc-subtitle", "none", "presentation", "tab"],
Expand Down Expand Up @@ -1755,11 +1763,6 @@ export class ARIADefinitions {
validRoles: ["doc-subtitle", "none", "presentation", "tab"],
globalAriaAttributesValid: true
},
"hgroup": {
implicitRole: null,
validRoles: ["any"],
globalAriaAttributesValid: true
},
"hr": {
implicitRole: ["separator"],
validRoles: ["doc-pagebreak", "none", "presentation"],
Expand Down Expand Up @@ -1893,7 +1896,8 @@ export class ARIADefinitions {
"picture": {
implicitRole: null,
validRoles: null,
globalAriaAttributesValid: false
globalAriaAttributesValid: false,
/** otherAriaAttributes: [aria-hidden] */
},
"pre": {
implicitRole: null,
Expand All @@ -1903,7 +1907,8 @@ export class ARIADefinitions {
"progress": {
implicitRole: ["progressbar"],
validRoles: null,
globalAriaAttributesValid: true
globalAriaAttributesValid: true,
/** otherAriaAttributes: [aria-valuemax] */
},
"q": {
implicitRole: null,
Expand Down Expand Up @@ -2072,7 +2077,8 @@ export class ARIADefinitions {
implicitRole: ["link"],
//roleCondition: " when non-empty href attribute is present",
validRoles: ["button", "checkbox", "doc-backlink", "doc-biblioref", "doc-glossref", "doc-noteref", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "radio", "switch", "tab", "treeitem"],
globalAriaAttributesValid: true
globalAriaAttributesValid: true,
disallowedOtherAriaAttributes: ["aria-diabled='true'"]
},
"without-href": {
implicitRole: null,
Expand All @@ -2091,7 +2097,7 @@ export class ARIADefinitions {
"without-href": {
implicitRole: null,
//roleCondition: " when href attribute is not present",
validRoles: null,
validRoles: ["button", "link"],
globalAriaAttributesValid: true
}
},
Expand All @@ -2115,7 +2121,13 @@ export class ARIADefinitions {
}
},
"footer": {
"des-section-article": {
"des-section-article-aside-main-nav": {
implicitRole: null,
//roleCondition: " when descendant of an article, aside, main, nav or section element",
validRoles: ["doc-footnote", "group", "none", "presentation"],
globalAriaAttributesValid: true
},
"role-complementary-article-main-navigation-region": {
implicitRole: null,
//roleCondition: " when descendant of an article, aside, main, nav or section element",
validRoles: ["doc-footnote", "group", "none", "presentation"],
Expand Down Expand Up @@ -2150,7 +2162,13 @@ export class ARIADefinitions {
// },

"header": {
"des-section-article": {
"des-section-article-aside-main-nav": {
implicitRole: null,
//roleCondition: " when descendant of an article, aside, main, nav or section element",
validRoles: ["group", "none", "presentation"],
globalAriaAttributesValid: true
},
"role-complementary-article-main-navigation-region": {
implicitRole: null,
//roleCondition: " when descendant of an article, aside, main, nav or section element",
validRoles: ["group", "none", "presentation"],
Expand All @@ -2168,7 +2186,7 @@ export class ARIADefinitions {
"img-with-alt-text": {
implicitRole: ["img"],
//roleCondition: " when alt attribute has text (is not empty)",
validRoles: ["button", "checkbox", "doc-cover", "link", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "progressbar", "scrollbar", "separator", "slider", "switch", "tab", "treeitem"],
validRoles: ["button", "checkbox", "doc-cover", "link", "menuitem", "menuitemcheckbox", "menuitemradio", "option", "progressbar", "radio", "scrollbar", "separator", "slider", "switch", "tab", "treeitem"],
globalAriaAttributesValid: true
},
"img-with-empty-alt": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,24 @@ const DEPRECATED_HTML_GLOBAL_ATTRIBUTES = [

const DEPRECATED_ROLES = [
/** deprecated aria roles: https://www.w3.org/TR/wai-aria-1.2/ */
"directory"
/**
* the aria deprecation will be better handled in ARIADefinition.ts
* "directory"
*/
]

const DEPRECATED_ARIA_GLOBAL_ATTRIBUTES = [
/** add deprecated aria global attributes: https://www.w3.org/TR/wai-aria-1.2/ */
"aria-grabbed", "aria-dropeffect"
/**
* the aria deprecation will be better handled in ARIADefinition.ts
* "aria-grabbed", "aria-dropeffect"
*/
]

const DEPRECATED_ARIA_ROLE_ATTRIBUTES = {
/** add deprecated aria role and attributes: https://www.w3.org/TR/wai-aria-1.2/ */
/**
* the aria deprecation will be better handled in ARIADefinition.ts
"alert" : ["aria-disabled", "aria-errormessage", "aria-haspopup", "aria-invalid"],
"alertdialog" : ["aria-disabled", "aria-errormessage", "aria-haspopup", "aria-invalid"],
"article" : ["aria-disabled", "aria-errormessage", "aria-haspopup", "aria-invalid"],
Expand Down Expand Up @@ -175,7 +183,7 @@ const DEPRECATED_HTML_GLOBAL_ATTRIBUTES = [
"treeitem" : ["aria-errormessage", "aria-invalid"],
"widget" : ["aria-disabled", "aria-errormessage", "aria-haspopup", "aria-invalid"],
"window" : ["aria-disabled", "aria-errormessage", "aria-haspopup", "aria-invalid"]

*/
}

function arrayToContextStr(obj, type) {
Expand Down Expand Up @@ -263,12 +271,12 @@ let a11yRulesElem: Rule[] = [
* html tags: https://dev.w3.org/html5/pf-summary/obsolete.html
*/
id: "element_attribute_deprecated",
context: arrayToContextStr(DEPRECATED_ELEMENTS, "HTML_ELEMENTS") + ", " +
arrayToContextStr(DEPRECATED_HTML_GLOBAL_ATTRIBUTES, "HTML_ATTRIBUTES") + ", " +
objToContextStr(DEPRECATED_ELEMENT_ATTRIBUTES, "HTML_ELEMENT_ATTRIBUTES") + ", " +
arrayToContextStr(DEPRECATED_ROLES, "ARIA_ROLES") + ", " +
arrayToContextStr(DEPRECATED_ARIA_GLOBAL_ATTRIBUTES, "ARIA_ATTRIBUTES") + ", " +
objToContextStr(DEPRECATED_ARIA_ROLE_ATTRIBUTES, "ARIA_ROLE_ATTRIBUTES"),
context: arrayToContextStr(DEPRECATED_ELEMENTS, "HTML_ELEMENTS") +
+ ", " + arrayToContextStr(DEPRECATED_HTML_GLOBAL_ATTRIBUTES, "HTML_ATTRIBUTES") +
+ ", " + objToContextStr(DEPRECATED_ELEMENT_ATTRIBUTES, "HTML_ELEMENT_ATTRIBUTES") +
(DEPRECATED_ROLES.length > 0 ? ", " + arrayToContextStr(DEPRECATED_ROLES, "ARIA_ROLES") : "") +
(DEPRECATED_ARIA_GLOBAL_ATTRIBUTES.length > 0 ? ", " + arrayToContextStr(DEPRECATED_ARIA_GLOBAL_ATTRIBUTES, "ARIA_ATTRIBUTES") : "") +
(Object.keys(DEPRECATED_ARIA_ROLE_ATTRIBUTES).length > 0 ? ", " + objToContextStr(DEPRECATED_ARIA_ROLE_ATTRIBUTES, "ARIA_ROLE_ATTRIBUTES") : ""),
run: (context: RuleContext, options?: {}): RuleResult | RuleResult[] => {
const ruleContext = context["dom"].node as Element;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@
<div role="listitem">an item in the directory</div>
</div>

<ul role="directory">
<li>an item in the directory, no explicit role</li>
<li role="listitem">an item in the directory with role=listitem</li>
</ul>

<ol role="directory">
<li>an item in the directory, no explicit role</li>
<li role="listitem">an item in the directory with role=listitem</li>
</ol>

<menu role="directory">
<li>an item in the directory, no explicit role</li>
<li role="listitem">an item in the directory with role=listitem</li>
Expand All @@ -53,68 +43,14 @@
UnitTest = {
ruleIds: ["element_attribute_deprecated"],
results: [{
"ruleId": "element_attribute_deprecated",
"value": [
"INFORMATION",
"FAIL"
],
"path": {
"dom": "/html[1]/body[1]/div[1]/div[1]",
"aria": "/document[1]/directory[1]"
},
"reasonId": "fail_aria_role",
"message": "The ARIA role \"directory\" is deprecated in ARIA 1.2",
"messageArgs": [
"directory"
],
"apiArgs": [],
"category": "Accessibility"
},
{
"ruleId": "element_attribute_deprecated",
"value": [
"INFORMATION",
"FAIL"
],
"path": {
"dom": "/html[1]/body[1]/div[1]/ul[1]",
"aria": "/document[1]/directory[2]"
},
"reasonId": "fail_aria_role",
"message": "The ARIA role \"directory\" is deprecated in ARIA 1.2",
"messageArgs": [
"directory"
],
"apiArgs": [],
"category": "Accessibility"
},
{
"ruleId": "element_attribute_deprecated",
"value": [
"INFORMATION",
"FAIL"
],
"path": {
"dom": "/html[1]/body[1]/div[1]/ol[1]",
"aria": "/document[1]/directory[3]"
},
"reasonId": "fail_aria_role",
"message": "The ARIA role \"directory\" is deprecated in ARIA 1.2",
"messageArgs": [
"directory"
],
"apiArgs": [],
"category": "Accessibility"
},
{
"ruleId": "element_attribute_deprecated",
"value": [
"INFORMATION",
"FAIL"
],
"path": {
"dom": "/html[1]/body[1]/div[1]/menu[1]",
"aria": "/document[1]/directory[4]"
"aria": "/document[1]/directory[2]"
},
"reasonId": "fail_elem",
"message": "The <menu> element is deprecated in HTML 5",
Expand Down

0 comments on commit c981d73

Please sign in to comment.