| 26 | // The method comes from the prototype because a control named or id'd |
| 27 | // "submit" masks form.submit. |
| 28 | function submit(element: Element): void { |
| 29 | const form = findForm(element) |
| 30 | if (!form) { |
| 31 | throw botError(NO_SUCH_ELEMENT, 'Element was not in a form, so could not submit.') |
| 32 | } |
| 33 | if (fire(form, EventType.SUBMIT, { submitter: null })) { |
| 34 | const win = (form.ownerDocument.defaultView || window) as Window & typeof globalThis |
| 35 | win.HTMLFormElement.prototype.submit.call(form) |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | // A control's form owner honours the form= attribute; anything else falls |
| 40 | // back to the nearest ancestor form. Reading .form off a <form> itself would |