[whatwg] questions regarding submit event timing

Glenn Maynard glenn at zewt.org
Mon May 2 08:52:29 PDT 2011


On Sun, May 1, 2011 at 9:14 PM, Hallvord R M Steen <hallvors at gmail.com> wrote:
> 1) What methods exactly cause the "scripted submit" flag to be set?

Load the one-page version (and hope your browser survives):

http://www.whatwg.org/specs/web-apps/current-work/

You can search for the text "scripted-submit" here.  The only place in
the HTML5 spec itself that sets this flag is submit()
(http://www.whatwg.org/specs/web-apps/current-work/#dom-form-submit),
although other specs could also use that flag.

> 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.

All events in the HTML5 spec are effectively synchronous; it uses
tasks to get the effect of what DOM Events calls an "asynchronous
event".  Step 6 says "fire a simple event that is cancelable named
submit, at form", which is strictly synchronous; if it was firing it
asynchronously it'd say "queue a task to fire a simple event".

(It's also possible for an entire algorithm to be running from a task,
in which case the event is synchronous with respect to the algorithm,
but the algorithm itself, including the event, is asynchronous with
respect to any script that triggered it.  Handling these common but
more complicated interactions is why this method is much clearer and
more powerful than the overgeneric "asynchronous event" concept.)

-- 
Glenn Maynard



More information about the whatwg mailing list