a11y: warn about href="javascript:..." (#4733)

pull/4746/head
Kalan 5 years ago committed by GitHub
parent 8c4e72647a
commit 56d1af493b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -428,7 +428,7 @@ export default class Element extends Node {
if (attribute) {
const value = attribute.get_static_value();
if (value === '' || value === '#') {
if (value === '' || value === '#' || /^\W*javascript:/i.test(value)) {
component.warn(attribute, {
code: `a11y-invalid-attribute`,
message: `A11y: '${value}' is not a valid ${attribute.name} attribute`

@ -1,3 +1,4 @@
<a>not actually a link</a>
<a href=''>invalid</a>
<a href='#'>invalid</a>
<a href='#'>invalid</a>
<a href="javascript:void(0)">invalid</a>

@ -43,5 +43,20 @@
"character": 61
},
"pos": 53
},
{
"code": "a11y-invalid-attribute",
"message": "A11y: 'javascript:void(0)' is not a valid href attribute",
"start": {
"line": 4,
"column": 3,
"character": 77
},
"end": {
"line": 4,
"column": 28,
"character": 102
},
"pos": 77
}
]

Loading…
Cancel
Save