UNPKG

@uuv/a11y

Version:

A javascript lib for running a11y validation based on multiple reference(RGAA, etc)

295 lines (294 loc) 13.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const model_1 = require("../../../model"); const query_1 = require("../../../query"); const selector_helper_1 = require("../selector-helper"); exports.default = [ model_1.AutoCheckA11yRule.from({ criterion: "5.1", wcag: "1.3.1 A", id: "5.1.1", elementType: "table", query: new query_1.CompliantAttributesQuery(new query_1.ByTagQuery(selector_helper_1.table.noCaption.buildSelector(selector_helper_1.table.selector.complex, "")), [ query_1.AttributeChecker.emptyAttribute("summary"), query_1.AttributeChecker.emptyHtmlNodeTargetedByTheAttribute("aria-describedby"), ]), description: "Table tag without summary", help: "set a summary to table" }), model_1.AutoCheckA11yRule.from({ criterion: "5.1", wcag: "1.3.1 A", id: "5.1.1", elementType: "table", query: new query_1.CompliantAttributesQuery(new query_1.ByTagQuery(selector_helper_1.table.noCaption.buildSelector(selector_helper_1.table.hasComplexHeader.buildSelector([], "table"), "")), [ query_1.AttributeChecker.emptyHtmlNodeTargetedByTheAttribute("aria-describedby"), ]), description: "Element with role table without summary", help: "set a summary to table" }), model_1.ManualCheckA11yRule.from({ criterion: "5.2", wcag: "1.3.1 A", id: "5.2.1", elementType: "table", query: new query_1.ByTagQuery([ ...selector_helper_1.table.caption.buildSelector(selector_helper_1.table.selector.complex, ""), ...selector_helper_1.table.summary.buildSelector(selector_helper_1.table.selector.complex, ""), ...selector_helper_1.table.ariaDescribedBy.buildSelector(selector_helper_1.table.selector.complex, ""), ...selector_helper_1.table.caption.buildSelector(selector_helper_1.table.hasComplexHeader.buildSelector([], "table"), ""), ...selector_helper_1.table.summary.buildSelector(selector_helper_1.table.hasComplexHeader.buildSelector([], "table"), ""), ...selector_helper_1.table.ariaDescribedBy.buildSelector(selector_helper_1.table.hasComplexHeader.buildSelector([], "table"), "") ]), description: "if present, attributes summary(before html5), aria-describedby or child tag <caption> must be relevant", attributes: [ "summary", "aria-describedby", "child:caption" ], help: "adapt these attributes to be relevant" }), model_1.ManualCheckA11yRule.from({ criterion: "5.3", wcag: "1.3.2 A, 4.1.2 A", id: "5.3.1", elementType: "table", query: new query_1.ByTagQuery([ selector_helper_1.table.selector.withFormatting, ]), description: "table with presentation role must have revelant content", attributes: [ "child:td" ], help: "adapt these <td> children content to be relevant" }), model_1.AutoCheckA11yRule.from({ criterion: "5.4", wcag: "1.3.1 A", id: "5.4.1", elementType: "table", query: new query_1.CompliantAttributesQuery(new query_1.ByTagQuery([ ...selector_helper_1.table.noCaption.buildSelector([selector_helper_1.table.selector.withData], "table"), ]), [ query_1.AttributeChecker.emptyAttribute("title"), query_1.AttributeChecker.emptyAttribute("aria-label"), query_1.AttributeChecker.emptyHtmlNodeTargetedByTheAttribute("aria-labelledby"), ]), description: "table must have title", attributes: [ "child:caption", "title", "aria-label", "aria-labelledby" ], help: "set one of these attributes" }), model_1.ManualCheckA11yRule.from({ criterion: "5.5", wcag: "1.3.1 A", id: "5.5.1", elementType: "table", query: new query_1.ByTagQuery([ ...selector_helper_1.table.caption.buildSelector([selector_helper_1.table.selector.withData], "table"), ...selector_helper_1.table.title.buildSelector([selector_helper_1.table.selector.withData], "table"), ...selector_helper_1.table.ariaLabel.buildSelector([selector_helper_1.table.selector.withData], "table"), ...selector_helper_1.table.ariaLabelledBy.buildSelector([selector_helper_1.table.selector.withData], "table"), ]), description: "table must have a revelant title", attributes: [ "child:caption", "title", "aria-label", "aria-labelledby" ], help: "adapt one of these attributes to be revelant" }), model_1.ManualCheckA11yRule.from({ criterion: "5.6", wcag: "1.3.1 A", id: "5.6.1", elementType: "table", query: new query_1.ByTagQuery([ selector_helper_1.table.selector.withData, "[role=table]" ]), description: "table column header must be set properly", help: "each table column header must be set with tag <th> or role=\"columnheader\"" }), model_1.ManualCheckA11yRule.from({ criterion: "5.6", wcag: "1.3.1 A", id: "5.6.2", elementType: "table", query: new query_1.ByTagQuery([ selector_helper_1.table.selector.withData, "[role=table]" ]), description: "table line header must be set properly", help: "each table line header must be set with tag <th> or role=\"rowheader\"" }), model_1.ManualCheckA11yRule.from({ criterion: "5.6", wcag: "1.3.1 A", id: "5.6.3", elementType: "table", query: new query_1.ByTagQuery([ selector_helper_1.table.selector.withData, "[role=table]" ]), description: "each header does not apply to the entire row or column must be set properly" }), model_1.ManualCheckA11yRule.from({ criterion: "5.6", wcag: "1.3.1 A", id: "5.6.4", elementType: "table", query: new query_1.ByTagQuery([ selector_helper_1.table.selector.withData, "[role=table]" ]), description: "each cell associated with several headers structured using a <th> or <td> tag" }), model_1.AutoCheckA11yRule.from({ criterion: "5.7", wcag: "1.3.1 A", id: "5.7.1", elementType: "table", query: new query_1.CompliantAttributesQuery(new query_1.ByTagQuery([ ...selector_helper_1.table.thColumnHeader.buildSelector([selector_helper_1.table.selector.withData], "table"), ]), [ query_1.AttributeChecker.notUniqueId(), query_1.AttributeChecker.emptyAttribute("scope"), query_1.AttributeChecker.notEquals("role", ["rowheader", "columnheader"]) ]), description: "Table column header attributes", help: "Correctly set table column header attributes" }), model_1.AutoCheckA11yRule.from({ criterion: "5.7", wcag: "1.3.1 A", id: "5.7.1", elementType: "table", query: new query_1.CompliantAttributesQuery(new query_1.ByTagQuery([ ...selector_helper_1.table.thRowHeader.buildSelector([selector_helper_1.table.selector.withData], "table"), ]), [ query_1.AttributeChecker.notUniqueId(), query_1.AttributeChecker.emptyAttribute("scope"), query_1.AttributeChecker.notEquals("role", ["rowheader", "columnheader"]) ]), description: "Table row header attributes", help: "Correctly set table row header attributes" }), model_1.AutoCheckA11yRule.from({ criterion: "5.7", wcag: "1.3.1 A", id: "5.7.2", elementType: "table", query: new query_1.CompliantAttributesQuery(new query_1.ByTagQuery([ ...selector_helper_1.table.thColumnHeader.buildSelector([selector_helper_1.table.selector.withData], "table"), ]), [ query_1.AttributeChecker.notEmptyAttribute("scope"), query_1.AttributeChecker.notEquals("scope", ["col"]) ]), description: "Table column header scope attribute", help: "Set table column header scope attribute to col" }), model_1.AutoCheckA11yRule.from({ criterion: "5.7", wcag: "1.3.1 A", id: "5.7.2", elementType: "table", query: new query_1.CompliantAttributesQuery(new query_1.ByTagQuery([ ...selector_helper_1.table.thRowHeader.buildSelector([selector_helper_1.table.selector.withData], "table"), ]), [ query_1.AttributeChecker.notEmptyAttribute("scope"), query_1.AttributeChecker.notEquals("scope", ["row"]) ]), description: "Table row header scope attribute", help: "Set table column header scope attribute to row" }), model_1.AutoCheckA11yRule.from({ criterion: "5.7", wcag: "1.3.1 A", id: "5.7.3", elementType: "table", query: new query_1.OrQuery([ new query_1.CompliantAttributesQuery(new query_1.ByTagQuery([ "table:not([role=presentation]) tr:not(:first-child) th:not(:first-child)" ]), [ query_1.AttributeChecker.notUniqueId() ]), new query_1.CompliantAttributesQuery(new query_1.ByTagQuery([ "table:not([role=presentation]) tr:not(:first-child) th:not(:first-child)" ]), [ query_1.AttributeChecker.notEmptyAttribute("scope") ]), new query_1.CompliantAttributesQuery(new query_1.ByTagQuery([ "table:not([role=presentation]) tr:not(:first-child) th:not(:first-child)" ]), [ query_1.AttributeChecker.equals("role", ["rowheader", "columnheader"]) ]) ]), description: "each header does not apply to the entire row or column must be set properly" }), model_1.ManualCheckA11yRule.from({ criterion: "5.7", wcag: "1.3.1 A", id: "5.7.4", elementType: "table", query: new query_1.ByTagQuery([ selector_helper_1.table.selector.withData, "[role=table]" ]), description: "Each cell associated with several headers, the header attribute must be filled in correctly.", help: "Each cell associated with several headers, the header attribute must contain the list of ids referring to the target headers." }), model_1.AutoCheckA11yRule.from({ criterion: "5.7", wcag: "1.3.1 A", id: "5.7.5", elementType: "table", query: new query_1.CompliantAttributesQuery(new query_1.ByTagQuery([ "table:not([role=presentation]) tr:first-child th", "[role=table] tr:first-child th" ]), [ query_1.AttributeChecker.notEmptyAttribute("role"), query_1.AttributeChecker.notEquals("role", ["columnheader"]) ]), description: "Table column header role attribute", help: "Set table column header role attribute to 'columnheader'" }), model_1.AutoCheckA11yRule.from({ criterion: "5.7", wcag: "1.3.1 A", id: "5.7.5", elementType: "table", query: new query_1.CompliantAttributesQuery(new query_1.ByTagQuery([ "table:not([role=presentation]) tr:not(:first-child) th:first-child", "[role=table] tr:not(:first-child) th:first-child" ]), [ query_1.AttributeChecker.notEmptyAttribute("role"), query_1.AttributeChecker.notEquals("role", ["rowheader"]) ]), description: "Table row header role attribute", help: "Set table row header role attribute to 'rowheader'" }), model_1.AutoCheckA11yRule.from({ criterion: "5.8", wcag: "1.3.1 A", id: "5.8.1", elementType: "table", query: new query_1.ByTagQuery([ selector_helper_1.table.selector.withFormatting + "[summary]", selector_helper_1.table.selector.withFormatting + ":has(caption)", selector_helper_1.table.selector.withFormatting + ":has(thead)", selector_helper_1.table.selector.withFormatting + ":has(th)", selector_helper_1.table.selector.withFormatting + ":has(tfoot)", selector_helper_1.table.selector.withFormatting + " :has(> [role=rowheader])", selector_helper_1.table.selector.withFormatting + " :has(> [role=columnheader])", selector_helper_1.table.selector.withFormatting + " td[scope]", selector_helper_1.table.selector.withFormatting + " td[headers]", selector_helper_1.table.selector.withFormatting + " td[axis]", ]), description: "table with presentation role must have revelant content", attributes: [ "child:td" ], help: "adapt these <td> children content to be relevant" }) ];