Skip to content

Commit c2ea115

Browse files
committed
Use literal prop
1 parent dd3cba1 commit c2ea115

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/rules/a11y-no-visually-hidden-interactive-element.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const {getProp, getPropValue} = require('jsx-ast-utils')
1+
const {getProp, getLiteralPropValue} = require('jsx-ast-utils')
22
const {getElementType} = require('../utils/get-element-type')
33
const {generateObjSchema} = require('eslint-plugin-jsx-a11y/lib/util/schemas')
44

@@ -32,9 +32,12 @@ const checkIfInteractiveElement = (context, node) => {
3232
const checkIfVisuallyHiddenAndInteractive = (context, options, node, isParentVisuallyHidden) => {
3333
const {className, componentName} = options
3434
if (node.type === 'JSXElement') {
35-
const classes = getPropValue(getProp(node.openingElement.attributes, 'className'))
35+
const classes = getLiteralPropValue(getProp(node.openingElement.attributes, 'className'))
3636
const isVisuallyHiddenElement = node.openingElement.name.name === componentName
37-
const hasSROnlyClass = typeof classes !== 'undefined' && classes.includes(className)
37+
let hasSROnlyClass = false
38+
if (classes != null) {
39+
hasSROnlyClass = classes.includes(className)
40+
}
3841
let isHidden = false
3942
if (hasSROnlyClass || isVisuallyHiddenElement || !!isParentVisuallyHidden) {
4043
if (checkIfInteractiveElement(context, node)) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy