Skip to content

Commit e77c35e

Browse files
Apply suggestions from code review
Co-authored-by: Keith Cirkel <[email protected]>
1 parent fc80126 commit e77c35e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/rules/a11y-svg-has-accessible-name.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ module.exports = {
1414
return {
1515
JSXOpeningElement: node => {
1616
const elementType = getElementType(context, node)
17+
if (elementType !== 'svg') return
1718

1819
// Check if there is a nested title element that is the first child of the `<svg>`
1920
const hasNestedTitleAsFirstChild =
20-
node.parent.children.length &&
21-
node.parent.children[0].type === 'JSXElement' &&
22-
node.parent.children[0].openingElement.name.name === 'title'
21+
node.parent.children?.[0]?.type === 'JSXElement' &&
22+
node.parent.children?.[0]?.openingElement?.name?.name === 'title'
2323

2424
// Check if `aria-label` or `aria-labelledby` is set
2525
const hasAccessibleName = hasProp(node.attributes, 'aria-label') || hasProp(node.attributes, 'aria-labelledby')

0 commit comments

Comments
 (0)