Skip to content

Commit 035434f

Browse files
authored
Merge pull request #1040 from equalizedigital/william/pro-178-links-with-role-of-tab-should-be-excluded-from-improper-link
Enhancement: Add a test case for links with role of tab that should pass
2 parents 9d0c6d2 + d988723 commit 035434f

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/pageScanner/checks/link-has-valid-href-or-role.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ export default {
1515
const href = node.getAttribute( 'href' );
1616
const role = node.getAttribute( 'role' ) || '';
1717

18-
// Allow if it's a button role
19-
if ( role.toLowerCase().split( /\s+/ ).includes( 'button' ) ) {
18+
// Allow roles of button or tab
19+
if (
20+
role
21+
.toLowerCase()
22+
.split( /\s+/ )
23+
.some( ( r ) => [ 'button', 'tab' ].includes( r ) )
24+
) {
2025
return true;
2126
}
2227

tests/jest/rules/linkImproper.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ describe( 'Link Improper Rule', () => {
115115
element.setAttribute( 'aria-hidden', 'true' );
116116
},
117117
},
118+
{
119+
name: 'Passes with role="tab"',
120+
html: '<a href="#" role="tab">Link with role of tab</a>',
121+
shouldPass: true,
122+
},
118123
] )( '$name', async ( { html, shouldPass, setup } ) => {
119124
document.body.innerHTML = html;
120125

0 commit comments

Comments
 (0)