diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts index 7a70e603a77f..ab5ddd2f072f 100644 --- a/src/compiler/compile/nodes/Element.ts +++ b/src/compiler/compile/nodes/Element.ts @@ -424,6 +424,25 @@ export default class Element extends Node { }); } + if (name === "onmouseover") { + if (!this.attributes.find(i => i.name === 'onFocus')) { + component.warn(attribute, { + code: `a11y-mouse-events-have-key-events`, + message: `A11y: onMouseOver must be accompanied by onFocus for accessibility.` + }); + } + } + + if (name === "onmouseout") { + if (!this.attributes.find(i => i.name === 'onBlur')) { + component.warn(attribute, { + code: `a11y-mouse-events-have-key-events`, + message: `A11y: onMouseOut must be accompanied by onBlur for accessibility.` + }); + } + } + + attribute_map.set(attribute.name, attribute); }); } 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..efdf95a0a1e3 --- /dev/null +++ b/test/validator/samples/a11y-mouse-events-have-key-events/input.svelte @@ -0,0 +1,4 @@ +