File tree 3 files changed +27
-3
lines changed
3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,8 @@ import {
11
11
getElementType ,
12
12
hasAriaLabel ,
13
13
isAriaHidden ,
14
+ isMatchingElement ,
14
15
makeDocsURL ,
15
- makeKebabCase ,
16
16
} from "../utils" ;
17
17
18
18
function isLabelElement (
@@ -23,8 +23,8 @@ function isLabelElement(
23
23
| AST . VExpressionContainer ,
24
24
{ labelComponents = [ ] } : FormControlHasLabelOptions
25
25
) {
26
- const allLabelComponents = labelComponents . map ( makeKebabCase ) . concat ( "label" ) ;
27
- return node . type === "VElement" && allLabelComponents . includes ( getElementType ( node ) ) ;
26
+ const allLabelComponents = labelComponents . concat ( "label" ) ;
27
+ return isMatchingElement ( node , allLabelComponents ) ;
28
28
}
29
29
30
30
function hasLabelElement ( node : AST . VElement , options : FormControlHasLabelOptions ) : boolean {
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export { default as isAriaHidden } from "./utils/isAriaHidden";
14
14
export { default as isAttribute } from "./utils/isAttribute" ;
15
15
export { default as isHiddenFromScreenReader } from "./utils/isHiddenFromScreenReader" ;
16
16
export { default as isInteractiveElement } from "./utils/isInteractiveElement" ;
17
+ export { default as isMatchingElement } from "./utils/isMatchingElement" ;
17
18
export { default as isPresentationRole } from "./utils/isPresentationRole" ;
18
19
export { default as makeDocsURL } from "./utils/makeDocsURL" ;
19
20
export { default as makeKebabCase } from "./utils/makeKebabCase" ;
Original file line number Diff line number Diff line change
1
+ import type { AST } from "vue-eslint-parser" ;
2
+
3
+ import getElementType from "./getElementType" ;
4
+ import makeKebabCase from "./makeKebabCase" ;
5
+
6
+ function isMatchingElement (
7
+ node :
8
+ | AST . VElement
9
+ | AST . VDocumentFragment
10
+ | AST . VText
11
+ | AST . VExpressionContainer ,
12
+ searchArray : string [ ]
13
+ ) {
14
+ if ( ! ( node . type === "VElement" ) ) return false ;
15
+
16
+ const elementType = getElementType ( node ) ;
17
+
18
+ return searchArray . some ( ( item : string ) => {
19
+ return makeKebabCase ( item ) === elementType ;
20
+ } ) ;
21
+ }
22
+
23
+ export default isMatchingElement ;
You can’t perform that action at this time.
0 commit comments