Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(620)

Unified Diff: Source/core/html/HTMLFormElement.cpp

Issue 177683004: Don't delay submit in onsubmit event handler (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Send form data at time of method invocation Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/html/HTMLFormElement.cpp
diff --git a/Source/core/html/HTMLFormElement.cpp b/Source/core/html/HTMLFormElement.cpp
index 7e5a7859d87924d3238f3ac9ad3b22a6f35a131a..c24d0926c9bee5372d4314696cfa538fbe36a2fd 100644
--- a/Source/core/html/HTMLFormElement.cpp
+++ b/Source/core/html/HTMLFormElement.cpp
@@ -303,11 +303,12 @@ bool HTMLFormElement::prepareForSubmission(Event* event)
RefPtr<FormState> formState = FormState::create(this, controlNamesAndValues, &document(), NotSubmittedByJavaScript);
frame->loader().client()->dispatchWillSendSubmitEvent(formState.release());
+ // Set flag before submission as dispatchEvent could trigger another event
+ m_isSubmittingOrPreparingForSubmission = false;
+
if (dispatchEvent(Event::createCancelableBubble(EventTypeNames::submit)))
m_shouldSubmit = true;
- m_isSubmittingOrPreparingForSubmission = false;
-
if (m_shouldSubmit)
submit(event, true, true, NotSubmittedByJavaScript);

Powered by Google App Engine
This is Rietveld 408576698