The preload function of a page is called even if preventDefault is called on onclick
, onmousedown
and ontouchstart
on a data-sveltekit-preload-data="tap" anchor
#12510
Labels
bug
Something isn't working
Describe the bug
I found this odd behaviour when using an anchor element that included a child that should not trigger navigation. Tried doing
event.preventDefault
on the child as it prevents the navigation but still calls the preload function.I don't think it is the intended behaviour as the fetched data is not used for the (cancelled) navigation and might be stale if a later navigation happens.
It is a one line fix. Just checking
event.defaultPrevented
here would prevent the preloading.Reproduction
Was not able to run the https://node.new/sveltekit with the latest svelte v5 and sveltekit versions but I think the bug is obvious as the mousedown and touchstart listeners are attached just a few lines below the
tap()
function and there is noevent.defaultPrevented
check on any of them, unlike the click event, which is checking it here.Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: