99// Rule Definition
1010// ----------------------------------------------------------------------------
1111
12- import hasAttribute from '../util/hasAttribute ' ;
12+ import getAttribute from '../util/getAttribute ' ;
1313import getAttributeValue from '../util/getAttributeValue' ;
1414
1515const mouseOverErrorMessage = 'onMouseOver must be accompanied by onFocus for accessibility.' ;
@@ -20,11 +20,11 @@ module.exports = context => ({
2020 const attributes = node . attributes ;
2121
2222 // 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 ) ;
2525
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' ) ;
2828 const onFocusValue = getAttributeValue ( hasOnFocus ) ;
2929
3030 if ( hasOnFocus === false || onFocusValue === null || onFocusValue === undefined ) {
@@ -36,10 +36,10 @@ module.exports = context => ({
3636 }
3737
3838 // 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' ) ;
4343 const onBlurValue = getAttributeValue ( hasOnBlur ) ;
4444
4545 if ( hasOnBlur === false || onBlurValue === null || onBlurValue === undefined ) {
0 commit comments