(element: HTMLInputElement)
| 301 | } |
| 302 | |
| 303 | function getRadiosInGroup(element: HTMLInputElement): HTMLInputElement[] { |
| 304 | if (!element.form) { |
| 305 | // Radio buttons outside a form - query the document |
| 306 | return Array.from( |
| 307 | getOwnerDocument(element).querySelectorAll<HTMLInputElement>( |
| 308 | `input[type="radio"][name="${CSS.escape(element.name)}"]` |
| 309 | ) |
| 310 | ).filter(radio => !radio.form); |
| 311 | } |
| 312 | |
| 313 | // namedItem returns RadioNodeList (iterable) for 2+ elements, but a single Element for exactly 1. |
| 314 | // https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormControlsCollection/namedItem |
| 315 | const radioList = element.form.elements.namedItem(element.name); |
| 316 | let ownerWindow = getOwnerWindow(element); |
| 317 | if (radioList instanceof ownerWindow.RadioNodeList) { |
| 318 | return Array.from(radioList).filter( |
| 319 | (el): el is HTMLInputElement => el instanceof ownerWindow.HTMLInputElement |
| 320 | ); |
| 321 | } |
| 322 | if (radioList instanceof ownerWindow.HTMLInputElement) { |
| 323 | return [radioList]; |
| 324 | } |
| 325 | return []; |
| 326 | } |
| 327 | |
| 328 | function isTabbableRadio(element: HTMLInputElement): boolean { |
| 329 | if (element.checked) { |
no test coverage detected