Technical problem that produces a Javascript error

I am working on an admin functionality for a customer. For the time being no link to a demo showing the problem.

On that page there is a Bootstrap4 Button. Clicking on it injects a form. and replaces the button with the native replaceChild function. The form is not login related, and Avast registers it as such.

Once the form is submitted and the server confirms the transaction my script removes the form again with replaceChild and inserts the previous button. After completing everything from my side, the JS error console shows an error, pinpointing it to an AVAST Password form event. I am guessing it is because the event is attached to the form, which I just removed, and therefore the AVAST event handler points to a not anymore existing form.

IMO AVAST Passwords should be able to resolve this scenario gracefully. Be it that it doesn’t bother to install event handlers on forms it has determined are not login related, or if a form goes missing, catches the particular error exception. The 2nd suggestion is more general, as it could work on login forms too.

If required I can see how I can make a mockup demo of this issue.