W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2011

[whatwg] questions regarding submit event timing

From: Mounir Lamouri <mounir.lamouri@gmail.com>
Date: Mon, 02 May 2011 10:29:38 +0000
Message-ID: <4DBE8792.2090402@gmail.com>
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
Received on Monday, 2 May 2011 03:29:38 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:32 UTC