(element: Element)
| 40 | // back to the nearest ancestor form. Reading .form off a <form> itself would |
| 41 | // find a control named "form" instead. |
| 42 | function findForm(element: Element): HTMLFormElement | null { |
| 43 | if (element.tagName.toUpperCase() === 'FORM') { |
| 44 | return element as HTMLFormElement |
| 45 | } |
| 46 | const owner = (element as HTMLInputElement).form |
| 47 | if (owner) { |
| 48 | return owner |
| 49 | } |
| 50 | return element.closest('form') |
| 51 | } |
| 52 | |
| 53 | export default submit |