File tree Expand file tree Collapse file tree 4 files changed +16
-43
lines changed
src/compiler/compile/nodes
test/validator/samples/a11y-no-redundant-roles Expand file tree Collapse file tree 4 files changed +16
-43
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' svelte ' : patch
3
+ ---
4
+
5
+ fix: relax a11y "no redundant role" rule for li, ul, ol
Original file line number Diff line number Diff line change @@ -694,7 +694,11 @@ export default class Element extends Node {
694
694
) ;
695
695
}
696
696
// no-redundant-roles
697
- if ( current_role === get_implicit_role ( this . name , attribute_map ) ) {
697
+ if (
698
+ current_role === get_implicit_role ( this . name , attribute_map ) &&
699
+ // <ul role="list"> is ok because CSS list-style:none removes the semantics and this is a way to bring them back
700
+ ! [ 'ul' , 'ol' , 'li' ] . includes ( this . name )
701
+ ) {
698
702
component . warn (
699
703
attribute ,
700
704
compiler_warnings . a11y_no_redundant_roles ( current_role )
Original file line number Diff line number Diff line change 19
19
<h5 role =" heading" >heading</h5 >
20
20
<h6 role =" heading" >heading</h6 >
21
21
<hr role =" separator" />
22
- <li role =" listitem" />
22
+ <!-- < li role="listitem" /> allowed since CSS list-style none removes semantic meaning and role brings it back -- >
23
23
<link role =" link" />
24
- <main role =" main" ></ main >
24
+ <main role =" main" / >
25
25
<menu role =" list" />
26
26
<nav role =" navigation" />
27
- <ol role =" list" />
27
+ <!-- < ol role="list" /> allowed, see comment above -- >
28
28
<optgroup role =" group" />
29
29
<option role =" option" />
30
30
<output role =" status" />
37
37
<tfoot role =" rowgroup" />
38
38
<thead role =" rowgroup" />
39
39
<tr role =" row" />
40
- <ul role =" list" />
40
+ <!--< ul role="list" /> allowed, see comment above -- >
41
41
42
42
<!-- Tested header/footer not nested in section/article -->
43
- <header role =" banner" ></ header >
44
- <footer role =" contentinfo" ></ footer >
43
+ <header role =" banner" / >
44
+ <footer role =" contentinfo" / >
45
45
46
46
<!-- Allowed -->
47
47
<!-- svelte-ignore a11y-no-noninteractive-element-to-interactive-role -->
Original file line number Diff line number Diff line change 251
251
"line" : 21
252
252
}
253
253
},
254
- {
255
- "code" : " a11y-no-redundant-roles" ,
256
- "end" : {
257
- "column" : 19 ,
258
- "line" : 22
259
- },
260
- "message" : " A11y: Redundant role 'listitem'" ,
261
- "start" : {
262
- "column" : 4 ,
263
- "line" : 22
264
- }
265
- },
266
254
{
267
255
"code" : " a11y-no-redundant-roles" ,
268
256
"end" : {
311
299
"line" : 26
312
300
}
313
301
},
314
- {
315
- "code" : " a11y-no-redundant-roles" ,
316
- "end" : {
317
- "column" : 15 ,
318
- "line" : 27
319
- },
320
- "message" : " A11y: Redundant role 'list'" ,
321
- "start" : {
322
- "column" : 4 ,
323
- "line" : 27
324
- }
325
- },
326
302
{
327
303
"code" : " a11y-no-redundant-roles" ,
328
304
"end" : {
467
443
"line" : 39
468
444
}
469
445
},
470
- {
471
- "code" : " a11y-no-redundant-roles" ,
472
- "end" : {
473
- "column" : 15 ,
474
- "line" : 40
475
- },
476
- "message" : " A11y: Redundant role 'list'" ,
477
- "start" : {
478
- "column" : 4 ,
479
- "line" : 40
480
- }
481
- },
482
446
{
483
447
"code" : " a11y-no-redundant-roles" ,
484
448
"end" : {
You can’t perform that action at this time.
0 commit comments