When you try to prevent a form element from element from submitting by attaching an event listener and preventing the default, it will still submit the form:
const form = document.querySelector("form");
form.addEventListener('submit', e => e.preventDefault());
/* click submit */
it should not submit the form and no navigation should happen. But it does.
Describe the bug
When you try to prevent a form element from element from submitting by attaching an event listener and preventing the default, it will still submit the form:
it should not submit the form and no navigation should happen. But it does.
To Reproduce
I did create a minimal reproducible example here:
https://github.com/LukasBombach/happy-dom-form-prevent-default-bug
yarn install
)yarn test
Expected behavior
Using preventDefault on a submit event of a form should stop it from navigating.
After submitting a form in
happy-dom
there will be a navigation nonetheless.Screenshots
--
Device:
Additional context
I can see this using vitest
1.6.0
happy-dom14.12.0