File tree 3 files changed +18
-2
lines changed
src/compiler/compile/nodes
test/validator/samples/a11y-anchor-is-valid
3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -428,7 +428,7 @@ export default class Element extends Node {
428
428
if ( attribute ) {
429
429
const value = attribute . get_static_value ( ) ;
430
430
431
- if ( value === '' || value === '#' ) {
431
+ if ( value === '' || value === '#' || / ^ \W * j a v a s c r i p t : / i . test ( value ) ) {
432
432
component . warn ( attribute , {
433
433
code : `a11y-invalid-attribute` ,
434
434
message : `A11y: '${ value } ' is not a valid ${ attribute . name } attribute`
Original file line number Diff line number Diff line change 1
1
<a >not actually a link</a >
2
2
<a href =' ' >invalid</a >
3
- <a href =' #' >invalid</a >
3
+ <a href =' #' >invalid</a >
4
+ <a href =" javascript:void(0)" >invalid</a >
Original file line number Diff line number Diff line change 43
43
"character" : 61
44
44
},
45
45
"pos" : 53
46
+ },
47
+ {
48
+ "code" : " a11y-invalid-attribute" ,
49
+ "message" : " A11y: 'javascript:void(0)' is not a valid href attribute" ,
50
+ "start" : {
51
+ "line" : 4 ,
52
+ "column" : 3 ,
53
+ "character" : 77
54
+ },
55
+ "end" : {
56
+ "line" : 4 ,
57
+ "column" : 28 ,
58
+ "character" : 102
59
+ },
60
+ "pos" : 77
46
61
}
47
62
]
You can’t perform that action at this time.
0 commit comments