Skip to content

Commit

Permalink
fix(aria-lablledby): work with virtual and serial virtual nodes (#2341)
Browse files Browse the repository at this point in the history
* fix(aria-lablledby): work with virtual and serial virtual nodes

* Update lib/checks/shared/aria-labelledby.json

Co-authored-by: Wilco Fiers <[email protected]>

Co-authored-by: Wilco Fiers <[email protected]>
  • Loading branch information
straker and WilcoFiers authored Jul 6, 2020
1 parent a6c880b commit c1f3db7
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 77 deletions.
22 changes: 11 additions & 11 deletions doc/rule-descriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

| Rule ID | Description | Impact | Tags | Issue Type |
| :------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------ | :---------------- | :------------------------------------------------------------------------------------ | :------------------------- |
| [area-alt](https://dequeuniversity.com/rules/axe/3.5/area-alt?application=RuleDescription) | Ensures &lt;area&gt; elements of image maps have alternate text | Critical | cat.text-alternatives, wcag2a, wcag111, wcag244, wcag412, section508, section508.22.a | failure |
| [area-alt](https://dequeuniversity.com/rules/axe/3.5/area-alt?application=RuleDescription) | Ensures &lt;area&gt; elements of image maps have alternate text | Critical | cat.text-alternatives, wcag2a, wcag111, wcag244, wcag412, section508, section508.22.a | failure, needs&nbsp;review |
| [aria-allowed-attr](https://dequeuniversity.com/rules/axe/3.5/aria-allowed-attr?application=RuleDescription) | Ensures ARIA attributes are allowed for an element&apos;s role | Critical | cat.aria, wcag2a, wcag412 | failure |
| [aria-hidden-body](https://dequeuniversity.com/rules/axe/3.5/aria-hidden-body?application=RuleDescription) | Ensures aria-hidden=&apos;true&apos; is not present on the document body. | Critical | cat.aria, wcag2a, wcag412 | failure |
| [aria-hidden-focus](https://dequeuniversity.com/rules/axe/3.5/aria-hidden-focus?application=RuleDescription) | Ensures aria-hidden elements do not contain focusable elements | Serious | cat.name-role-value, wcag2a, wcag412, wcag131 | failure, needs&nbsp;review |
Expand All @@ -27,7 +27,7 @@
| [aria-valid-attr](https://dequeuniversity.com/rules/axe/3.5/aria-valid-attr?application=RuleDescription) | Ensures attributes that begin with aria- are valid ARIA attributes | Critical | cat.aria, wcag2a, wcag412 | failure |
| [audio-caption](https://dequeuniversity.com/rules/axe/3.5/audio-caption?application=RuleDescription) | Ensures &lt;audio&gt; elements have captions | Critical | cat.time-and-media, wcag2a, wcag121, section508, section508.22.a | needs&nbsp;review |
| [blink](https://dequeuniversity.com/rules/axe/3.5/blink?application=RuleDescription) | Ensures &lt;blink&gt; elements are not used | Serious | cat.time-and-media, wcag2a, wcag222, section508, section508.22.j | failure |
| [button-name](https://dequeuniversity.com/rules/axe/3.5/button-name?application=RuleDescription) | Ensures buttons have discernible text | Critical | cat.name-role-value, wcag2a, wcag412, section508, section508.22.a | failure |
| [button-name](https://dequeuniversity.com/rules/axe/3.5/button-name?application=RuleDescription) | Ensures buttons have discernible text | Critical | cat.name-role-value, wcag2a, wcag412, section508, section508.22.a | failure, needs&nbsp;review |
| [bypass](https://dequeuniversity.com/rules/axe/3.5/bypass?application=RuleDescription) | Ensures each page has at least one mechanism for a user to bypass navigation and jump straight to the content | Serious | cat.keyboard, wcag2a, wcag241, section508, section508.22.o | failure |
| [color-contrast](https://dequeuniversity.com/rules/axe/3.5/color-contrast?application=RuleDescription) | Ensures the contrast between foreground and background colors meets WCAG 2 AA contrast ratio thresholds | Serious | cat.color, wcag2aa, wcag143 | failure, needs&nbsp;review |
| [definition-list](https://dequeuniversity.com/rules/axe/3.5/definition-list?application=RuleDescription) | Ensures &lt;dl&gt; elements are structured correctly | Serious | cat.structure, wcag2a, wcag131 | failure |
Expand All @@ -37,24 +37,24 @@
| [duplicate-id-aria](https://dequeuniversity.com/rules/axe/3.5/duplicate-id-aria?application=RuleDescription) | Ensures every id attribute value used in ARIA and in labels is unique | Critical | cat.parsing, wcag2a, wcag411 | failure |
| [duplicate-id](https://dequeuniversity.com/rules/axe/3.5/duplicate-id?application=RuleDescription) | Ensures every id attribute value is unique | Minor | cat.parsing, wcag2a, wcag411 | failure |
| [form-field-multiple-labels](https://dequeuniversity.com/rules/axe/3.5/form-field-multiple-labels?application=RuleDescription) | Ensures form field does not have multiple label elements | Moderate | cat.forms, wcag2a, wcag332 | needs&nbsp;review |
| [frame-title](https://dequeuniversity.com/rules/axe/3.5/frame-title?application=RuleDescription) | Ensures &lt;iframe&gt; and &lt;frame&gt; elements contain a non-empty title attribute | Serious | cat.text-alternatives, wcag2a, wcag241, wcag412, section508, section508.22.i | failure |
| [frame-title](https://dequeuniversity.com/rules/axe/3.5/frame-title?application=RuleDescription) | Ensures &lt;iframe&gt; and &lt;frame&gt; elements contain a non-empty title attribute | Serious | cat.text-alternatives, wcag2a, wcag241, wcag412, section508, section508.22.i | failure, needs&nbsp;review |
| [html-has-lang](https://dequeuniversity.com/rules/axe/3.5/html-has-lang?application=RuleDescription) | Ensures every HTML document has a lang attribute | Serious | cat.language, wcag2a, wcag311 | failure |
| [html-lang-valid](https://dequeuniversity.com/rules/axe/3.5/html-lang-valid?application=RuleDescription) | Ensures the lang attribute of the &lt;html&gt; element has a valid value | Serious | cat.language, wcag2a, wcag311 | failure |
| [html-xml-lang-mismatch](https://dequeuniversity.com/rules/axe/3.5/html-xml-lang-mismatch?application=RuleDescription) | Ensure that HTML elements with both valid lang and xml:lang attributes agree on the base language of the page | Moderate | cat.language, wcag2a, wcag311 | failure |
| [image-alt](https://dequeuniversity.com/rules/axe/3.5/image-alt?application=RuleDescription) | Ensures &lt;img&gt; elements have alternate text or a role of none or presentation | Critical | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | failure |
| [input-button-name](https://dequeuniversity.com/rules/axe/3.5/input-button-name?application=RuleDescription) | Ensures input buttons have discernible text | Critical | cat.name-role-value, wcag2a, wcag412, section508, section508.22.a | failure |
| [input-image-alt](https://dequeuniversity.com/rules/axe/3.5/input-image-alt?application=RuleDescription) | Ensures &lt;input type=&quot;image&quot;&gt; elements have alternate text | Critical | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | failure |
| [label](https://dequeuniversity.com/rules/axe/3.5/label?application=RuleDescription) | Ensures every form element has a label | Minor, Critical | cat.forms, wcag2a, wcag412, wcag131, section508, section508.22.n | failure |
| [link-name](https://dequeuniversity.com/rules/axe/3.5/link-name?application=RuleDescription) | Ensures links have discernible text | Serious | cat.name-role-value, wcag2a, wcag412, wcag244, section508, section508.22.a | failure |
| [image-alt](https://dequeuniversity.com/rules/axe/3.5/image-alt?application=RuleDescription) | Ensures &lt;img&gt; elements have alternate text or a role of none or presentation | Critical | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | failure, needs&nbsp;review |
| [input-button-name](https://dequeuniversity.com/rules/axe/3.5/input-button-name?application=RuleDescription) | Ensures input buttons have discernible text | Critical | cat.name-role-value, wcag2a, wcag412, section508, section508.22.a | failure, needs&nbsp;review |
| [input-image-alt](https://dequeuniversity.com/rules/axe/3.5/input-image-alt?application=RuleDescription) | Ensures &lt;input type=&quot;image&quot;&gt; elements have alternate text | Critical | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | failure, needs&nbsp;review |
| [label](https://dequeuniversity.com/rules/axe/3.5/label?application=RuleDescription) | Ensures every form element has a label | Minor, Critical | cat.forms, wcag2a, wcag412, wcag131, section508, section508.22.n | failure, needs&nbsp;review |
| [link-name](https://dequeuniversity.com/rules/axe/3.5/link-name?application=RuleDescription) | Ensures links have discernible text | Serious | cat.name-role-value, wcag2a, wcag412, wcag244, section508, section508.22.a | failure, needs&nbsp;review |
| [list](https://dequeuniversity.com/rules/axe/3.5/list?application=RuleDescription) | Ensures that lists are structured correctly | Serious | cat.structure, wcag2a, wcag131 | failure |
| [listitem](https://dequeuniversity.com/rules/axe/3.5/listitem?application=RuleDescription) | Ensures &lt;li&gt; elements are used semantically | Serious | cat.structure, wcag2a, wcag131 | failure |
| [marquee](https://dequeuniversity.com/rules/axe/3.5/marquee?application=RuleDescription) | Ensures &lt;marquee&gt; elements are not used | Serious | cat.parsing, wcag2a, wcag222 | failure |
| [meta-refresh](https://dequeuniversity.com/rules/axe/3.5/meta-refresh?application=RuleDescription) | Ensures &lt;meta http-equiv=&quot;refresh&quot;&gt; is not used | Critical | cat.time-and-media, wcag2a, wcag2aaa, wcag221, wcag224, wcag325 | failure |
| [object-alt](https://dequeuniversity.com/rules/axe/3.5/object-alt?application=RuleDescription) | Ensures &lt;object&gt; elements have alternate text | Serious | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | failure |
| [role-img-alt](https://dequeuniversity.com/rules/axe/3.5/role-img-alt?application=RuleDescription) | Ensures [role=&apos;img&apos;] elements have alternate text | Serious | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | failure |
| [object-alt](https://dequeuniversity.com/rules/axe/3.5/object-alt?application=RuleDescription) | Ensures &lt;object&gt; elements have alternate text | Serious | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | failure, needs&nbsp;review |
| [role-img-alt](https://dequeuniversity.com/rules/axe/3.5/role-img-alt?application=RuleDescription) | Ensures [role=&apos;img&apos;] elements have alternate text | Serious | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | failure, needs&nbsp;review |
| [scrollable-region-focusable](https://dequeuniversity.com/rules/axe/3.5/scrollable-region-focusable?application=RuleDescription) | Elements that have scrollable content should be accessible by keyboard | Moderate | wcag2a, wcag211 | failure |
| [server-side-image-map](https://dequeuniversity.com/rules/axe/3.5/server-side-image-map?application=RuleDescription) | Ensures that server-side image maps are not used | Minor | cat.text-alternatives, wcag2a, wcag211, section508, section508.22.f | needs&nbsp;review |
| [svg-img-alt](https://dequeuniversity.com/rules/axe/3.5/svg-img-alt?application=RuleDescription) | Ensures svg elements with an img, graphics-document or graphics-symbol role have an accessible text | Serious | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | failure |
| [svg-img-alt](https://dequeuniversity.com/rules/axe/3.5/svg-img-alt?application=RuleDescription) | Ensures svg elements with an img, graphics-document or graphics-symbol role have an accessible text | Serious | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | failure, needs&nbsp;review |
| [td-headers-attr](https://dequeuniversity.com/rules/axe/3.5/td-headers-attr?application=RuleDescription) | Ensure that each cell in a table using the headers refers to another cell in that table | Serious | cat.tables, wcag2a, wcag131, section508, section508.22.g | failure, needs&nbsp;review |
| [th-has-data-cells](https://dequeuniversity.com/rules/axe/3.5/th-has-data-cells?application=RuleDescription) | Ensure that each table header in a data table refers to data cells | Serious | cat.tables, wcag2a, wcag131, section508, section508.22.g | failure, needs&nbsp;review |
| [valid-lang](https://dequeuniversity.com/rules/axe/3.5/valid-lang?application=RuleDescription) | Ensures lang attributes have valid values | Serious | cat.language, wcag2aa, wcag312 | failure |
Expand Down
6 changes: 5 additions & 1 deletion lib/checks/shared/aria-labelledby-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { sanitize } from '../../commons/text';
import { arialabelledbyText } from '../../commons/aria';

function ariaLabelledbyEvaluate(node) {
return !!sanitize(arialabelledbyText(node));
try {
return !!sanitize(arialabelledbyText(node));
} catch (e) {
return undefined;
}
}

export default ariaLabelledbyEvaluate;
3 changes: 2 additions & 1 deletion lib/checks/shared/aria-labelledby.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"impact": "serious",
"messages": {
"pass": "aria-labelledby attribute exists and references elements that are visible to screen readers",
"fail": "aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty"
"fail": "aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty",
"incomplete": "ensure aria-labelledby references an existing element"
}
}
}
Loading

0 comments on commit c1f3db7

Please sign in to comment.