-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Proposal: allow a mode of form.submit() that behaves like clicking a submit button #4187
Description
Right now, the following snippets of code behave differently:
form.submit();const button = document.createElement('input');
button.type = 'submit';
form.append(button);
button.click();
button.remove();Per https://html.spec.whatwg.org/#concept-form-submit, the second one gets a lot more useful behaviors: interactive validation, submit events, and the potential of replacement-enabled navigation when the document is not yet completely loaded.
Wouldn't it be nice if we could do
form.submit({ interactive: true });or similar? (Bikeshed the name at your leisure.)
This is of special concern to folks trying to create custom form controls that behave like submit buttons, or for any attempts to explain the platform's elements in terms of imperative constructs.
Credit to @manucorporat for this idea; he pointed out that Ionic is currently using the hacky workaround for their custom submit button. That makes me sad and it would be nice if we could help them not do that.
/cc @tkent-google @rniwa @smaug---- @travisleithead for implementer thoughts.