Change in Lead Form Embed JS?

Hello,
We’ve been working with HubSpot Embedded Lead Forms for a few years now.
In order to detect when lead forms has been submitted, we use the `onFormSubmit` event to trigger one of our own custom methods in a JavaScript wrapper.
Beginning this past week, we noticed that on submission of the embedded Lead Form, there was an error coming from HubSpot’s JavaScript file:
//js.hsforms.net/forms/shell.js
The same error also happened when attempting to use:
//js.hsforms.net/forms/embed/v2.js
Error description:
When clicking the Submit button on the embedded lead form, the browser console threw a TypeError that `t.dispatchEvent is not a function`.
My question: Is this `dispatchEvent` new? Or have there been any updates to this file recently?

We have not updated our wrapper or logic from our end since February 2022, so it was quite surprising when we found the Submit button on all HubSpot forms ceased to work and began throwing this error.

We have been able to workaround it with a fix to our wrapper, but would like to better understand what happened, if this fix will work long-term, and if we can better plan for avoiding this type of issue in the future.

Hey, @MCarreiro :waving_hand: Thanks for reaching out. Is this issue persisting? If so, can you share a link to an affected page, please?

Best,

Jaycee

Hi Jaycee,
This was an example of a player where it was occurring:
https://players.brightcove.net/5384493786001/ROlKAJiB9_default/index.html?videoId=5504190768001
We were able to workaround the issue by adding `dispatchEvent` to our JavaScript wrapper:

window.jQuery = window.jQuery || (() => ({
 // these are all methods required by HubSpot
 change: () => {},
 trigger: () => {},
 dispatchEvent: () => {}
}));

Previously, our wrapper was only adding `change` and `trigger` if jQuery could not be found, and up until last week, we were not experiencing any issues with form submission.
Thank you,
-Michael

Hi @Jaycee_Lewis, I wanted to check if there were any updates or will there be any investigation into this? Was the embed plugin updated at any point recently? Or perhaps, were any third-party libraries, such as jQuery updated that could have caused this change in support for dispatchEvent?

Thank you,

-Michael

HI @Jaycee_Lewis , We haven’t heard anything back with regards to this issue we experienced in November. Are there any updates or can we expect to hear anything?
Thank you,

-Michael