9
9
// Rule Definition
10
10
// ----------------------------------------------------------------------------
11
11
12
- import getAttribute from '../util/getAttribute ' ;
13
- import getAttributeValue from '../util/getAttributeValue' ;
12
+ import { getProp , getPropValue } from 'jsx-ast-utils ' ;
13
+
14
14
15
15
const mouseOverErrorMessage = 'onMouseOver must be accompanied by onFocus for accessibility.' ;
16
16
const mouseOutErrorMessage = 'onMouseOut must be accompanied by onBlur for accessibility.' ;
@@ -20,12 +20,12 @@ module.exports = context => ({
20
20
const attributes = node . attributes ;
21
21
22
22
// Check onmouseover / onfocus pairing.
23
- const onMouseOver = getAttribute ( attributes , 'onMouseOver' ) ;
24
- const onMouseOverValue = getAttributeValue ( onMouseOver ) ;
23
+ const onMouseOver = getProp ( attributes , 'onMouseOver' ) ;
24
+ const onMouseOverValue = getPropValue ( onMouseOver ) ;
25
25
26
26
if ( onMouseOver && ( onMouseOverValue !== null || onMouseOverValue !== undefined ) ) {
27
- const hasOnFocus = getAttribute ( attributes , 'onFocus' ) ;
28
- const onFocusValue = getAttributeValue ( hasOnFocus ) ;
27
+ const hasOnFocus = getProp ( attributes , 'onFocus' ) ;
28
+ const onFocusValue = getPropValue ( hasOnFocus ) ;
29
29
30
30
if ( hasOnFocus === false || onFocusValue === null || onFocusValue === undefined ) {
31
31
context . report ( {
@@ -36,11 +36,11 @@ module.exports = context => ({
36
36
}
37
37
38
38
// Checkout onmouseout / onblur pairing
39
- const onMouseOut = getAttribute ( attributes , 'onMouseOut' ) ;
40
- const onMouseOutValue = getAttributeValue ( onMouseOut ) ;
39
+ const onMouseOut = getProp ( attributes , 'onMouseOut' ) ;
40
+ const onMouseOutValue = getPropValue ( onMouseOut ) ;
41
41
if ( onMouseOut && ( onMouseOutValue !== null || onMouseOutValue !== undefined ) ) {
42
- const hasOnBlur = getAttribute ( attributes , 'onBlur' ) ;
43
- const onBlurValue = getAttributeValue ( hasOnBlur ) ;
42
+ const hasOnBlur = getProp ( attributes , 'onBlur' ) ;
43
+ const onBlurValue = getPropValue ( hasOnBlur ) ;
44
44
45
45
if ( hasOnBlur === false || onBlurValue === null || onBlurValue === undefined ) {
46
46
context . report ( {
0 commit comments