(element: HTMLInputElement)
| 317 | } |
| 318 | |
| 319 | function getRadiosInGroup(element: HTMLInputElement): HTMLInputElement[] { |
| 320 | if (!element.form) { |
| 321 | // Radio buttons outside a form - query the document |
| 322 | return Array.from( |
| 323 | getOwnerDocument(element).querySelectorAll<HTMLInputElement>( |
| 324 | `input[type="radio"][name="${CSS.escape(element.name)}"]` |
| 325 | ) |
| 326 | ).filter(radio => !radio.form); |
| 327 | } |
| 328 | |
| 329 | // namedItem returns RadioNodeList (iterable) for 2+ elements, but a single Element for exactly 1. |
| 330 | // https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormControlsCollection/namedItem |
| 331 | const radioList = element.form.elements.namedItem(element.name); |
| 332 | let ownerWindow = getOwnerWindow(element); |
| 333 | if (radioList instanceof ownerWindow.RadioNodeList) { |
| 334 | return Array.from(radioList).filter( |
| 335 | (el): el is HTMLInputElement => el instanceof ownerWindow.HTMLInputElement |
| 336 | ); |
| 337 | } |
| 338 | if (radioList instanceof ownerWindow.HTMLInputElement) { |
| 339 | return [radioList]; |
| 340 | } |
| 341 | return []; |
| 342 | } |
| 343 | |
| 344 | function isTabbableRadio(element: HTMLInputElement): boolean { |
| 345 | if (element.checked) { |
no test coverage detected