@@ -140,6 +140,53 @@ describe( 'Link Improper Rule', () => {
140140 html : '<a href="#" role="menuitem">Menu without aria-expanded</a>' ,
141141 shouldPass : false ,
142142 } ,
143+
144+ // Named anchor (jump target) cases
145+ {
146+ name : 'Passes when empty anchor is used as a named jump target' ,
147+ html : '<a id="meet-the-team"></a>' ,
148+ shouldPass : true ,
149+ } ,
150+ {
151+ name : 'Passes when whitespace-only anchor is used as a named jump target' ,
152+ html : '<a id="section-top"> </a>' ,
153+ shouldPass : true ,
154+ } ,
155+ {
156+ name : 'Passes when legacy name-only anchor is used as a jump target' ,
157+ html : '<a name="section-top"></a>' ,
158+ shouldPass : true ,
159+ } ,
160+ {
161+ name : 'Fails when legacy name-only anchor has text' ,
162+ html : '<a name="section-top">Text</a>' ,
163+ shouldPass : false ,
164+ } ,
165+ {
166+ name : 'Fails when anchor has id and text content but no href' ,
167+ html : '<a id="meet-the-team">Meet the Team</a>' ,
168+ shouldPass : false ,
169+ } ,
170+ {
171+ name : 'Fails when anchor has id and empty href' ,
172+ html : '<a id="top" href=""></a>' ,
173+ shouldPass : false ,
174+ } ,
175+ {
176+ name : 'Fails when anchor has id and child image but no href' ,
177+ html : '<a id="logo"><img src="logo.png" alt="Home"/></a>' ,
178+ shouldPass : false ,
179+ } ,
180+ {
181+ name : 'Fails when anchor is keyboard focusable via tabindex and has no href' ,
182+ html : '<a id="meet-the-team" tabindex="0"></a>' ,
183+ shouldPass : false ,
184+ } ,
185+ {
186+ name : 'Passes when anchor has tabindex of -1 and no href' ,
187+ html : '<a id="meet-the-team" tabindex="-1"></a>' ,
188+ shouldPass : true ,
189+ } ,
143190 ] ) ( '$name' , async ( { html, shouldPass, setup } ) => {
144191 document . body . innerHTML = html ;
145192
0 commit comments