Skip to content

Commit b05b0cb

Browse files
Do not look up as prop
1 parent 8abef65 commit b05b0cb

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/rules/a11y-no-title-attribute.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module.exports = {
5050
create(context) {
5151
return {
5252
JSXElement: node => {
53-
const elementType = getElementType(context, node.openingElement)
53+
const elementType = getElementType(context, node.openingElement, true)
5454
if (elementType !== `iframe` && ifSemanticElement(context, node)) {
5555
const titleProp = getPropValue(getProp(node.openingElement.attributes, `title`))
5656
if (titleProp) {

lib/utils/get-element-type.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ If a prop determines the type, it can be specified with `props`.
77
88
For now, we only support the mapping of one prop type to an element type, rather than combinations of props.
99
*/
10-
function getElementType(context, node, ignoreMap = false) {
10+
function getElementType(context, node, lazyElementCheck = false) {
1111
const {settings} = context
1212

13+
if (lazyElementCheck) {
14+
return elementType(node)
15+
}
16+
1317
// check if the node contains a polymorphic prop
1418
const polymorphicPropName = settings?.github?.polymorphicPropName ?? 'as'
1519
const rawElement = getLiteralPropValue(getProp(node.attributes, polymorphicPropName)) ?? elementType(node)
1620

1721
// if a component configuration does not exists, return the raw element
18-
if (ignoreMap || !settings?.github?.components?.[rawElement]) return rawElement
22+
if (!settings?.github?.components?.[rawElement]) return rawElement
1923

2024
const defaultComponent = settings.github.components[rawElement]
2125

0 commit comments

Comments
 (0)