question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug in modal.js: defaultPrevented called on jQuery.Event instead of isDefaultPrevented()

See original GitHub issue

Tried to prevent the hidePrevented.bs.modal event using e.preventDefault(), but it won’t work since the code checks for defaultPrevented instead of isDefaultPrevented().

The bug on this line: https://github.com/twbs/bootstrap/blob/v4.5.2/js/src/modal.js#L237

All the other events are properly using isDefaultPrevented() see for example this line: https://github.com/twbs/bootstrap/blob/v4.5.2/js/src/modal.js#L117

Here’s a simple fix: https://github.com/twbs/bootstrap/compare/v4.5.2...joakimriedel:joakimriedel/defaultPrevented?expand=1

Patch for 4.5.2 ?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
XhmikosRcommented, Sep 21, 2020

Thanks for the bug report and the PR. #31696 was merged.

Read more comments on GitHub >

github_iconTop Results From Across the Web

event.preventDefault() | jQuery API Documentation
We can use event.isDefaultPrevented() to determine if this method has been called by an event handler that was triggered by this event.
Read more >
Why is event.defaultPrevented undefined? - Stack Overflow
However, in my code, defaultPrevented is undefined (Chrome and Safari). Instead there is another property called: isDefaultPrevented which seems ...
Read more >
www.chulavistaconvis.com/dynamic/js/home.aspx
_Deferred(); // Catch cases where $(document).ready() is called after the ... isDefaultPrevented() ) { var old, special = jQuery.event.special[ type ] ...
Read more >
https://www.icaro2000.com/fallback/js/bootstrap.bu...
jQuery must be included before Bootstrap\\'s JavaScript. ... preventDefault() // work around Firefox bug #1540995\n return\n }\n\n if (initialButton.
Read more >
When to actually use preventDefault(), stopPropagation(), and ...
Some people have suggested to call preventDefault() and use 'e.defaultPrevented' to not handle an event instead of stopPropagation().
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found