Bug 1552301 - Implement form.requestSubmit(); r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D54278
This commit is contained in:
@@ -296,6 +296,32 @@ void HTMLFormElement::Submit(ErrorResult& aRv) {
|
||||
aRv = DoSubmitOrReset(nullptr, eFormSubmit);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#dom-form-requestsubmit
|
||||
void HTMLFormElement::RequestSubmit(nsGenericHTMLElement* aSubmitter,
|
||||
ErrorResult& aRv) {
|
||||
// 1. If submitter is not null, then:
|
||||
if (aSubmitter) {
|
||||
nsCOMPtr<nsIFormControl> fc = do_QueryObject(aSubmitter);
|
||||
|
||||
// 1.1. If submitter is not a submit button, then throw a TypeError.
|
||||
if (!fc || !fc->IsSubmitControl()) {
|
||||
aRv.ThrowTypeError<MSG_NOT_SUBMIT_BUTTON>();
|
||||
return;
|
||||
}
|
||||
|
||||
// 1.2. If submitter's form owner is not this form element, then throw a
|
||||
// "NotFoundError" DOMException.
|
||||
if (fc->GetFormElement() != this) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Otherwise, set submitter to this form element.
|
||||
// 3. Submit this form element, from submitter.
|
||||
MaybeSubmit(aSubmitter);
|
||||
}
|
||||
|
||||
void HTMLFormElement::Reset() {
|
||||
InternalFormEvent event(true, eFormReset);
|
||||
EventDispatcher::Dispatch(static_cast<nsIContent*>(this), nullptr, &event);
|
||||
|
||||
Reference in New Issue
Block a user