(
query: (container: HTMLElement, ...args: Arguments) => HTMLElement | null,
queryAllByName: string,
variant: Variant,
)
| 141 | |
| 142 | const wrapSingleQueryWithSuggestion = |
| 143 | <Arguments extends [...unknown[], WithSuggest]>( |
| 144 | query: (container: HTMLElement, ...args: Arguments) => HTMLElement | null, |
| 145 | queryAllByName: string, |
| 146 | variant: Variant, |
| 147 | ) => |
| 148 | (container: HTMLElement, ...args: Arguments) => { |
| 149 | const element = query(container, ...args) |
| 150 | const [{suggest = getConfig().throwSuggestions} = {}] = args.slice(-1) as [ |
| 151 | WithSuggest, |
| 152 | ] |
| 153 | if (element && suggest) { |
| 154 | const suggestion = getSuggestedQuery(element, variant) |
| 155 | if ( |
| 156 | suggestion && |
| 157 | !queryAllByName.endsWith(suggestion.queryName as string) |
| 158 | ) { |
| 159 | throw getSuggestionError(suggestion.toString(), container) |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | return element |
| 164 | } |
| 165 | |
| 166 | const wrapAllByQueryWithSuggestion = |
| 167 | < |
no test coverage detected