From 885eb1a5d5c5d86f926adf9d1f3d41d1a6245174 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Mon, 15 Mar 2021 11:36:47 +0800 Subject: [PATCH 1/1] DONOTCOMMIT: MDL-70990 testing --- lib/form/amd/src/events.js | 6 ++++++ lib/yui/src/event/js/event.js | 3 +++ 2 files changed, 9 insertions(+) diff --git a/lib/form/amd/src/events.js b/lib/form/amd/src/events.js index 5d5543e2fd7..00297c1486e 100644 --- a/lib/form/amd/src/events.js +++ b/lib/form/amd/src/events.js @@ -125,7 +125,11 @@ if (!legacyEventsRegistered) { // Watch for the new native formSubmittedByJavascript event, and trigger the legacy YUI event. document.addEventListener(eventTypes.formSubmittedByJavascript, e => { + window.console.log("Caught the native formSubmittedByJavascript event"); + if (e.detail.fallbackHandled) { + window.console.log("Stopped processing formSubmittedByJavascript: already handled."); + // This event was originally generated by a YUI event. // Do not generate another as this will recurse. return; @@ -135,6 +139,8 @@ if (!legacyEventsRegistered) { window.skipClientValidation = true; } + window.console.log("Firing the YUI M.core.event.FORM_SUBMIT_AJAX event on the form"); + // Trigger the legacy YUI event. const form = Y.one(e.target); form.fire( diff --git a/lib/yui/src/event/js/event.js b/lib/yui/src/event/js/event.js index 1506c8cb601..edb613f7aee 100644 --- a/lib/yui/src/event/js/event.js +++ b/lib/yui/src/event/js/event.js @@ -146,11 +146,14 @@ if (!eventsConfigured) { require(['core_form/events'], function(formEvents) { listenForMutation('form', function(form) { Y.one(form).on(M.core.event.FORM_SUBMIT_AJAX, function(e) { + window.console.log("Caught the YUI M.core.event.FORM_SUBMIT_AJAX event"); // Prevent cyclical calls. if (e && e.fallbackHandled) { + window.console.log("Stopped processing FORM_SUBMIT_AJAX: already handled."); return; } + window.console.log("Firing the native formSubmittedByJavascript event"); formEvents.notifyFormSubmittedByJavascript(form, window.skipValidation, true); }); }); -- 2.30.0