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