Skip to content

Commit

Permalink
Use literal prop
Browse files Browse the repository at this point in the history
  • Loading branch information
khiga8 committed Jul 18, 2023
1 parent dd3cba1 commit c2ea115
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/rules/a11y-no-visually-hidden-interactive-element.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {getProp, getPropValue} = require('jsx-ast-utils')
const {getProp, getLiteralPropValue} = require('jsx-ast-utils')
const {getElementType} = require('../utils/get-element-type')
const {generateObjSchema} = require('eslint-plugin-jsx-a11y/lib/util/schemas')

Expand Down Expand Up @@ -32,9 +32,12 @@ const checkIfInteractiveElement = (context, node) => {
const checkIfVisuallyHiddenAndInteractive = (context, options, node, isParentVisuallyHidden) => {
const {className, componentName} = options
if (node.type === 'JSXElement') {
const classes = getPropValue(getProp(node.openingElement.attributes, 'className'))
const classes = getLiteralPropValue(getProp(node.openingElement.attributes, 'className'))
const isVisuallyHiddenElement = node.openingElement.name.name === componentName
const hasSROnlyClass = typeof classes !== 'undefined' && classes.includes(className)
let hasSROnlyClass = false
if (classes != null) {
hasSROnlyClass = classes.includes(className)
}
let isHidden = false
if (hasSROnlyClass || isVisuallyHiddenElement || !!isParentVisuallyHidden) {
if (checkIfInteractiveElement(context, node)) {
Expand Down

0 comments on commit c2ea115

Please sign in to comment.