File tree Expand file tree Collapse file tree 3 files changed +18
-12
lines changed
src/compiler/compile/nodes
test/validator/samples/a11y-no-static-element-interactions Expand file tree Collapse file tree 3 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -602,10 +602,11 @@ export default class Element extends Node {
602
602
}
603
603
}
604
604
605
+ const has_dynamic_role = attribute_map . get ( 'role' ) && ! attribute_map . get ( 'role' ) . is_static ;
606
+
605
607
// no-static-element-interactions
606
- // TODO: investigate footer
607
- // TODO: investigate dynamic roles
608
608
if (
609
+ ! has_dynamic_role &&
609
610
! is_hidden_from_screen_reader ( this . name , attribute_map ) &&
610
611
! is_presentation_role ( role ) &&
611
612
! is_interactive_element ( this . name , attribute_map ) &&
Original file line number Diff line number Diff line change
1
+ <script >
2
+ const dynamicRole = " button" ;
3
+ </script >
4
+
1
5
<!-- valid -->
2
6
<button on:click ={() => {}} />
3
7
<div on:keydown ={() => {}} role =" button" />
4
8
<input type ="text" on:click ={() => {}} />
5
9
<div on:copy ={() => {}} />
6
10
<a href ="/foo" on:click ={() => {}}>link</a >
11
+ <div role ={dynamicRole } on:click ={() => {}} />
7
12
<!-- invalid -->
8
13
<div on:keydown ={() => {}} />
9
14
<!-- svelte-ignore a11y-missing-attribute -->
Original file line number Diff line number Diff line change 2
2
{
3
3
"code" : " a11y-no-static-element-interactions" ,
4
4
"end" : {
5
- "character" : 249 ,
5
+ "character" : 347 ,
6
6
"column" : 29 ,
7
- "line" : 8
7
+ "line" : 13
8
8
},
9
9
"message" : " A11y: <div> with keydown handler must have an ARIA role" ,
10
- "pos" : 220 ,
10
+ "pos" : 318 ,
11
11
"start" : {
12
- "character" : 220 ,
12
+ "character" : 318 ,
13
13
"column" : 0 ,
14
- "line" : 8
14
+ "line" : 13
15
15
}
16
16
},
17
17
{
18
18
"code" : " a11y-no-static-element-interactions" ,
19
19
"end" : {
20
- "character" : 372 ,
20
+ "character" : 470 ,
21
21
"column" : 76 ,
22
- "line" : 10
22
+ "line" : 15
23
23
},
24
24
"message" : " A11y: <a> with mousedown, mouseup handlers must have an ARIA role" ,
25
- "pos" : 296 ,
25
+ "pos" : 394 ,
26
26
"start" : {
27
- "character" : 296 ,
27
+ "character" : 394 ,
28
28
"column" : 0 ,
29
- "line" : 10
29
+ "line" : 15
30
30
}
31
31
}
32
32
]
You can’t perform that action at this time.
0 commit comments