Created by: joke2k
Removing jQuery the target of the click event is not the A tag if the user clicks on a nested tag, ignoring the preventDefault and changing the hash in the url.
What this PR does:
- Add
event.delegateTarget
into the check for preventDefault - Test this behaviour
Details:
this code:
<a role="button" data-bs-toggle="collapse" class="collapsed" href="#collapse">
<span id="nested">Clickme</span>
</a>
<div id="collapse" class="collapse"></div>
bubbles ups the default behaviour and changes the URL appending #collapse to it because the event.target
is not an A
tag, this let fail the check for event.preventDefault
.
See on bs5:
On bs4 jQuery did the work:
it happened with this commit https://github.com/twbs/bootstrap/commit/69e4d4f3ac897870e8186e22b19c5adf6043f3d4#diff-3cc7f0d8580d17c90274789ffc45552c56fed69ac7404d65e88ccccb81ffff31R378