Skip to content

Commit d462768

Browse files
committed
restrict to valid known tags and custom elements
1 parent 9bcca51 commit d462768

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/queries/alt-text.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@ import {
1010
} from '../../types'
1111
import {buildQueries} from './all-utils'
1212

13+
// Valid tags are img, input, area and custom elements
14+
const VALID_TAG_REGEXP = /^(img|input|area|.+-.+)$/i
15+
1316
const queryAllByAltText: AllByBoundAttribute = (
1417
container,
1518
alt,
1619
options: MatcherOptions = {},
1720
) => {
1821
checkContainerType(container)
19-
return queryAllByAttribute('alt', container, alt, options)
22+
return queryAllByAttribute('alt', container, alt, options).filter(node =>
23+
VALID_TAG_REGEXP.test(node.tagName),
24+
)
2025
}
2126

2227
const getMultipleError: GetErrorFunction<[unknown]> = (c, alt) =>

0 commit comments

Comments
 (0)