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 {
694694 ) ;
695695 }
696696 // 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+ ) {
698702 component . warn (
699703 attribute ,
700704 compiler_warnings . a11y_no_redundant_roles ( current_role )
Original file line number Diff line number Diff line change 1919<h5 role =" heading" >heading</h5 >
2020<h6 role =" heading" >heading</h6 >
2121<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 -- >
2323<link role =" link" />
24- <main role =" main" ></ main >
24+ <main role =" main" / >
2525<menu role =" list" />
2626<nav role =" navigation" />
27- <ol role =" list" />
27+ <!-- < ol role="list" /> allowed, see comment above -- >
2828<optgroup role =" group" />
2929<option role =" option" />
3030<output role =" status" />
3737<tfoot role =" rowgroup" />
3838<thead role =" rowgroup" />
3939<tr role =" row" />
40- <ul role =" list" />
40+ <!--< ul role="list" /> allowed, see comment above -- >
4141
4242<!-- 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" / >
4545
4646<!-- Allowed -->
4747<!-- svelte-ignore a11y-no-noninteractive-element-to-interactive-role -->
Original file line number Diff line number Diff line change 251251 "line" : 21
252252 }
253253 },
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- },
266254 {
267255 "code" : " a11y-no-redundant-roles" ,
268256 "end" : {
311299 "line" : 26
312300 }
313301 },
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- },
326302 {
327303 "code" : " a11y-no-redundant-roles" ,
328304 "end" : {
467443 "line" : 39
468444 }
469445 },
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- },
482446 {
483447 "code" : " a11y-no-redundant-roles" ,
484448 "end" : {
You can’t perform that action at this time.
0 commit comments