diff --git a/src/scanner/custom-rules/display-accessible-names.ts b/src/scanner/custom-rules/display-accessible-names.ts
index 866041b2026..ce18642cb47 100644
--- a/src/scanner/custom-rules/display-accessible-names.ts
+++ b/src/scanner/custom-rules/display-accessible-names.ts
@@ -17,7 +17,7 @@ export const accessibleNamesConfiguration: RuleConfiguration = {
id: accessibleNamesCheckId,
//this list of roles and elements was derived from the ARIA 1.2 documentation (Section 5.2.8.4: Roles supporting name from author or content): https://www.w3.org/TR/wai-aria-1.2/#namefromauthor
selector:
- '[role=alert], [role=alertdialog], [role=application], [role=article], article, [role=banner], [role=blockquote], blockquote, [role=button], button, [role=cell], [role=checkbox], [role=columnheader], [role=combobox], [role=command], [role=complementary], [role=composite], [role=contentinfo], [role=definition], [role=dialog], [role=directory],[role=document], [role=feed], [role=figure], figure, [role=form], form,[role=grid], table, [role=gridcell], td, [role=group], fieldset, [role=heading], h1,h2, h3, h4, h5, h6, [role=img],img,[role=input], [role=landmark], [role=link], a, link, [role=list], ol, ul, [role=listbox], [role=listitem], li, [role=log], [role=main], [role=marquee],[role=math], [role=meter], meter, [role=menu], [role=menubar], [role=menuitem], [role=menuitemcheckbox], [role=menuitemradio], [role=navigation], nav, [role=note], [role=option], option, [role=progressbar], [role=radio], [role=radiogroup], [role=range], [role=region], section, [role=row], tr, [role=rowgroup], tbody, tfoot, thead, [role=rowheader], th[scope="row"], [role=scrollbar], [role=searchbox], [role=search], [role=select], select, [role=sectionhead], [role=separator], hr, [role=slider], [role=status], [role=spinbutton, [role=switch], [role=tab], [role=table], [role=tablelist], [role=tabpanel], [role=term], dfn, td, [role=textbox], textarea, th, [role=time], time, [role=timer], [role=toolbar], [role=tooltip], [role=tree], [role=treegrid], [role=treeitem], input,[role=input],[role=window]',
+ '[role=alert], [role=alertdialog], [role=application], [role=article], article, [role=banner], [role=blockquote], blockquote, [role=button], button, [role=cell], [role=checkbox], [role=columnheader], [role=combobox], [role=command], [role=complementary], [role=composite], [role=contentinfo], [role=definition], [role=dialog], [role=directory],[role=document], [role=feed], [role=figure], figure, [role=form], form,[role=grid], table, [role=gridcell], td, [role=group], fieldset, [role=heading], h1,h2, h3, h4, h5, h6, [role=img],img,[role=input], [role=landmark], [role=link], a, link, [role=list], [role=listbox], [role=listitem],li, ol, ul, [role=log], [role=main], [role=marquee],[role=math], [role=meter], meter,[role=menu], [role=menubar], [role=menuitem], [role=menuitemcheckbox], [role=menuitemradio], [role=navigation], nav, [role=note], [role=option], option, [role=progressbar], [role=radio], [role=radiogroup], [role=range], [role=region], [role=row], tr, [role=rowgroup], [role=rowheader], th[scope="row"], [role=scrollbar], [role=searchbox], [role=search], [role=select], select, [role=sectionhead], [role=separator], hr, [role=slider], [role=status], [role=spinbutton, [role=switch], [role=tab], [role=table], [role=tablelist], [role=tabpanel], [role=term], td, [role=textbox], textarea, th, [role=time], time, [role=timer], [role=toolbar], [role=tooltip], [role=tree], [role=treegrid], [role=treeitem], input,[role=input],[role=window]',
enabled: false,
any: [accessibleNamesCheckId],
matches: hasAccessibleName,
@@ -28,9 +28,18 @@ function hasAccessibleName(node: HTMLElement): boolean {
// this list of roles and elements were derived from the ARIA 1.2 documentation (Section 5.2.8.6: Roles which cannot be named): https://www.w3.org/TR/wai-aria-1.2/#namefromprohibited
const nameProhibitedSelectors: string =
'caption, figcaption, [role=caption], code, [role=code], del, [role=deletion], em, [role=emphasis],[role=generic], ins, [role=insertion], p, [role=paragraph], [role=presentation], [role=strong], strong, sub, sup, [role=subscript], [role=superscript], [role=none]';
+ const nativeElements: string = 'blockquote, figure, form, li, meter, time,section, tr'; // overwriting axe-cores accessible name value as their calculation tends to return the contents of these elements
if (axe.utils.matchesSelector(node, nameProhibitedSelectors)) {
return false;
}
+ if (
+ axe.utils.matchesSelector(node, nativeElements) &&
+ node.hasAttribute('aria-label') === false &&
+ node.hasAttribute('aria-labelledby') === false &&
+ node.hasAttribute('title') === false
+ ) {
+ return false;
+ }
if (AxeUtils.getAccessibleText(node) === '') {
return false;
}
diff --git a/src/tests/end-to-end/test-resources/accessible-names/accessible-names.html b/src/tests/end-to-end/test-resources/accessible-names/accessible-names.html
index 3d4fead4408..4db5076c38c 100644
--- a/src/tests/end-to-end/test-resources/accessible-names/accessible-names.html
+++ b/src/tests/end-to-end/test-resources/accessible-names/accessible-names.html
@@ -16,5 +16,134 @@
Page heading
This is just a paragraph. It should not have an Accessible name
Heading has empty accessible name
+ Files
+
+
+ This is not from author, so won't be highlighted
+
+
+
+
+ Some text
+ 60%
+ A meter
+ A section
+
+
+
+
+
+
+ Day |
+ Miles |
+
+
+ Tuesday |
+ 10 |
+
+
+
+
+ Day |
+ Miles |
+
+
+ Friday |
+ 30 |
+
+
+
+
+
+ Day |
+ Miles |
+
+
+ Tuesday |
+ 10 |
+
+
+
+
+ Day |
+ Miles |
+
+
+ Friday |
+ 30 |
+
+
+ This is the term element
+ Article element
+ Some blockquote text
+
+
+ The premiere show starts at today.
+
+
+
Contest Entrants
+
+ This table shows the total number of entrants (500) the contest accepted over
+ the past four weeks.
+
+
+
Let x = 10
+
+
+
+
+
+
+
+
+ New Tests
+
+
+
+ An unordered list. Highlight
+
+
+ An unordered second list. No highlight
+
+
+ An ordered list. Highlight
+
+
+ An ordered second list. No highlight
+
+
+ - orange
+ -
+ mango
+
+