[whatwg] questions regarding submit event timing

Mounir Lamouri mounir.lamouri at gmail.com
Mon May 2 03:29:38 PDT 2011


On 05/02/2011 01:14 AM, Hallvord R M Steen wrote:
> 1) What methods exactly cause the "scripted submit" flag to be set?
> It's obviously set if you call form.submit(), but will it be set in
> these two cases:
>
> HTML:<form><input type="submit"></form>
> JS: form.elements[0].click()
>
> or
> HTML:<form><input type="submit"></form>
> JS: form.elements[0].dispatchEvent( evt ) /* where evt is a 'click'
> event object  */
>
> I believe the answer should be yes in both cases but I'm not sure if
> it's clear from the spec.

As far as I know, the "scripted-submit" flag is only set when you call 
.submit() on the form element.

> 2) Is the event fired synchronously? (And is it fired synchronously
> for all three cases of scripted submits mentioned above?)
> Again, I think the answer is yes but I couldn't find this information
> in the spec when looking for it.

Like you, I didn't find the reference in the specs but I believe the 
event has to be fired synchronously given that you can cancel the 
submission by calling event.preventDefault(). Having the event fired 
asynchronously would be uselessly hard to manage.

--
Mounir



More information about the whatwg mailing list