A JavaScript implementation of a web browser without its graphical user interface
3.08k
stars
185
forks
source link
React `onClick` handler with `preventDefault()` on an anchor tag does not prevent navigation #1464
Closed
amitdahan closed 2 weeks ago
Describe the bug
An
<a href="https://example.com">Click me</a>
tag with a click handler that invokesevent.preventDefault()
should prevent the subsequent navigation.When doing this with pure DOM APIs:
This passes.
When doing the same, but passing through React (and its synthetic event handling):
This fails, but should pass.
To Reproduce
https://stackblitz.com/edit/stackblitz-starters-x99sjj?file=package.json
The "Pure DOM"-based test passes The React-based one fails
Expected behavior The React test should pass
Additional context In real DOM and in JSDom this works as expected