diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts
index 517ed3ceb679..8e89f2e70e76 100644
--- a/src/compiler/compile/nodes/Element.ts
+++ b/src/compiler/compile/nodes/Element.ts
@@ -515,6 +515,20 @@ export default class Element extends Node {
});
}
}
+
+ if (handlers_map.has('mouseover') && !handlers_map.has('focus')) {
+ component.warn(this, {
+ code: `a11y-mouse-events-have-key-events`,
+ message: `A11y: on:mouseover must be accompanied by on:focus for accessibility`
+ });
+ }
+
+ if (handlers_map.has('mouseout') && !handlers_map.has('blur')) {
+ component.warn(this, {
+ code: `a11y-mouse-events-have-key-events`,
+ message: `A11y: on:mouseout must be accompanied by on:blur for accessibility`
+ });
+ }
}
validate_bindings() {
diff --git a/test/validator/samples/a11y-mouse-events-have-key-events/input.svelte b/test/validator/samples/a11y-mouse-events-have-key-events/input.svelte
new file mode 100644
index 000000000000..3b67cc1f5605
--- /dev/null
+++ b/test/validator/samples/a11y-mouse-events-have-key-events/input.svelte
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/validator/samples/a11y-mouse-events-have-key-events/warnings.json b/test/validator/samples/a11y-mouse-events-have-key-events/warnings.json
new file mode 100644
index 000000000000..a86babe210c1
--- /dev/null
+++ b/test/validator/samples/a11y-mouse-events-have-key-events/warnings.json
@@ -0,0 +1,62 @@
+[
+ {
+ "code": "a11y-mouse-events-have-key-events",
+ "message": "A11y: on:mouseover must be accompanied by on:focus for accessibility",
+ "end": {
+ "character": 91,
+ "column": 27,
+ "line": 6
+ },
+ "start": {
+ "character": 64,
+ "column": 0,
+ "line": 6
+ },
+ "pos": 64
+ },
+ {
+ "code": "a11y-mouse-events-have-key-events",
+ "message": "A11y: on:mouseout must be accompanied by on:blur for accessibility",
+ "end": {
+ "character": 118,
+ "column": 26,
+ "line": 7
+ },
+ "start": {
+ "character": 92,
+ "column": 0,
+ "line": 7
+ },
+ "pos": 92
+ },
+ {
+ "code": "a11y-mouse-events-have-key-events",
+ "message": "A11y: on:mouseover must be accompanied by on:focus for accessibility",
+ "end": {
+ "character": 161,
+ "column": 42,
+ "line": 8
+ },
+ "start": {
+ "character": 119,
+ "column": 0,
+ "line": 8
+ },
+ "pos": 119
+ },
+ {
+ "code": "a11y-mouse-events-have-key-events",
+ "message": "A11y: on:mouseout must be accompanied by on:blur for accessibility",
+ "end": {
+ "character": 204,
+ "column": 42,
+ "line": 9
+ },
+ "start": {
+ "character": 162,
+ "column": 0,
+ "line": 9
+ },
+ "pos": 162
+ }
+]
\ No newline at end of file