@@ -12,14 +12,11 @@ import {fuzzyMatches, matches, makeNormalizer} from './matches'
1212import { waitFor } from './wait-for'
1313import { getConfig } from './config'
1414
15- function getElementError ( message : string | null , container : HTMLElement ) {
15+ function getElementError ( message : string | null , container : Element ) {
1616 return getConfig ( ) . getElementError ( message , container )
1717}
1818
19- function getMultipleElementsFoundError (
20- message : string ,
21- container : HTMLElement ,
22- ) {
19+ function getMultipleElementsFoundError ( message : string , container : Element ) {
2320 return getElementError (
2421 `${ message } \n\n(If this is intentional, then use the \`*AllBy*\` variant of the query (like \`queryAllByText\`, \`getAllByText\`, or \`findAllByText\`)).` ,
2522 container ,
@@ -28,7 +25,7 @@ function getMultipleElementsFoundError(
2825
2926function queryAllByAttribute (
3027 attribute : string ,
31- container : HTMLElement ,
28+ container : Element ,
3229 text : Matcher ,
3330 { exact = true , collapseWhitespace, trim, normalizer} : MatcherOptions = { } ,
3431) : HTMLElement [ ] {
@@ -43,7 +40,7 @@ function queryAllByAttribute(
4340
4441function queryByAttribute (
4542 attribute : string ,
46- container : HTMLElement ,
43+ container : Element ,
4744 text : Matcher ,
4845 options ?: MatcherOptions ,
4946) {
@@ -64,7 +61,7 @@ function makeSingleQuery<Arguments extends unknown[]>(
6461 allQuery : QueryMethod < Arguments , HTMLElement [ ] > ,
6562 getMultipleError : GetErrorFunction < Arguments > ,
6663) {
67- return ( container : HTMLElement , ...args : Arguments ) => {
64+ return ( container : Element , ...args : Arguments ) => {
6865 const els = allQuery ( container , ...args )
6966 if ( els . length > 1 ) {
7067 const elementStrings = els
@@ -86,7 +83,7 @@ ${elementStrings}`,
8683
8784function getSuggestionError (
8885 suggestion : { toString ( ) : string } ,
89- container : HTMLElement ,
86+ container : Element ,
9087) {
9188 return getConfig ( ) . getElementError (
9289 `A better query is available, try this:
@@ -99,10 +96,10 @@ ${suggestion.toString()}
9996// this accepts a query function and returns a function which throws an error
10097// if an empty list of elements is returned
10198function makeGetAllQuery < Arguments extends unknown [ ] > (
102- allQuery : ( container : HTMLElement , ...args : Arguments ) => HTMLElement [ ] ,
99+ allQuery : ( container : Element , ...args : Arguments ) => HTMLElement [ ] ,
103100 getMissingError : GetErrorFunction < Arguments > ,
104101) {
105- return ( container : HTMLElement , ...args : Arguments ) => {
102+ return ( container : Element , ...args : Arguments ) => {
106103 const els = allQuery ( container , ...args )
107104 if ( ! els . length ) {
108105 throw getConfig ( ) . getElementError (
@@ -119,13 +116,13 @@ function makeGetAllQuery<Arguments extends unknown[]>(
119116// waitFor and passing a function which invokes the getter.
120117function makeFindQuery < QueryFor , QueryMatcher > (
121118 getter : (
122- container : HTMLElement ,
119+ container : Element ,
123120 text : QueryMatcher ,
124121 options : MatcherOptions ,
125122 ) => QueryFor ,
126123) {
127124 return (
128- container : HTMLElement ,
125+ container : Element ,
129126 text : QueryMatcher ,
130127 options : MatcherOptions ,
131128 waitForOptions : WaitForOptions ,
@@ -141,11 +138,11 @@ function makeFindQuery<QueryFor, QueryMatcher>(
141138
142139const wrapSingleQueryWithSuggestion =
143140 < Arguments extends [ ...unknown [ ] , WithSuggest ] > (
144- query : ( container : HTMLElement , ...args : Arguments ) => HTMLElement | null ,
141+ query : ( container : Element , ...args : Arguments ) => HTMLElement | null ,
145142 queryAllByName : string ,
146143 variant : Variant ,
147144 ) =>
148- ( container : HTMLElement , ...args : Arguments ) => {
145+ ( container : Element , ...args : Arguments ) => {
149146 const element = query ( container , ...args )
150147 const [ { suggest = getConfig ( ) . throwSuggestions } = { } ] = args . slice ( - 1 ) as [
151148 WithSuggest ,
@@ -169,11 +166,11 @@ const wrapAllByQueryWithSuggestion =
169166 // But that's not supported by TS so we have to `@ts-expect-error` every callsite
170167 Arguments extends [ ...unknown [ ] , WithSuggest ] ,
171168 > (
172- query : ( container : HTMLElement , ...args : Arguments ) => HTMLElement [ ] ,
169+ query : ( container : Element , ...args : Arguments ) => HTMLElement [ ] ,
173170 queryAllByName : string ,
174171 variant : Variant ,
175172 ) =>
176- ( container : HTMLElement , ...args : Arguments ) => {
173+ ( container : Element , ...args : Arguments ) => {
177174 const els = query ( container , ...args )
178175
179176 const [ { suggest = getConfig ( ) . throwSuggestions } = { } ] = args . slice ( - 1 ) as [
0 commit comments