diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts index 65000b9b5d..352d31a3db 100644 --- a/src/compiler/compile/nodes/Element.ts +++ b/src/compiler/compile/nodes/Element.ts @@ -599,6 +599,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' + }); + } + + 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' + }); + } } validate_bindings_foreign() { 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 0000000000..22de04f38a --- /dev/null +++ b/test/validator/samples/a11y-mouse-events-have-key-events/input.svelte @@ -0,0 +1,15 @@ + + +