diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts index b76ed875bc..002e09d9f9 100644 --- a/src/compiler/compile/nodes/Element.ts +++ b/src/compiler/compile/nodes/Element.ts @@ -61,11 +61,6 @@ const a11y_no_onchange = new Set([ 'option' ]); -const a11y_mouse_events = new Set([ - 'onMouseOver', - 'onMouseOut' -]); - const invisible_elements = new Set(['meta', 'html', 'script', 'style']); const valid_modifiers = new Set([ @@ -512,7 +507,7 @@ export default class Element extends Node { } } - if (a11y_mouse_events.has(this.name)) { + if (attribute_map.has('onMouseOver') || attribute_map.has('onMouseOut')) { if (attribute_map.has('onMouseOver') && !attribute_map.has('onFocus')) { component.warn(this, { code: `a11y-mouse-events-have-key-events`, 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 index fe51488c70..bb956c2cd3 100644 --- a/test/validator/samples/a11y-mouse-events-have-key-events/warnings.json +++ b/test/validator/samples/a11y-mouse-events-have-key-events/warnings.json @@ -1 +1,32 @@ -[] +[ + { + "code": "a11y-mouse-events-have-key-events", + "end": { + "character": 36, + "column": 36, + "line": 1 + }, + "message": "A11y: onMouseOver must be accompanied by onFocus for accessibility.", + "pos": 0, + "start": { + "character": 0, + "column": 0, + "line": 1 + } + }, + { + "code": "a11y-mouse-events-have-key-events", + "end": { + "character": 194, + "column": 59, + "line": 4 + }, + "message": "A11y: onMouseOut must be accompanied by onBlur for accessibility.", + "pos": 135, + "start": { + "character": 135, + "column": 0, + "line": 4 + } + } +]