mirror of
https://github.com/twbs/bootstrap.git
synced 2025-10-03 16:51:54 +02:00
Backport #28777.
Toast should allow prevent default for hide and show events
This commit is contained in:
@@ -82,7 +82,12 @@ class Toast {
|
||||
// Public
|
||||
|
||||
show() {
|
||||
$(this._element).trigger(Event.SHOW)
|
||||
const showEvent = $.Event(Event.SHOW)
|
||||
|
||||
$(this._element).trigger(showEvent)
|
||||
if (showEvent.isDefaultPrevented()) {
|
||||
return
|
||||
}
|
||||
|
||||
if (this._config.animation) {
|
||||
this._element.classList.add(ClassName.FADE)
|
||||
@@ -119,7 +124,13 @@ class Toast {
|
||||
return
|
||||
}
|
||||
|
||||
$(this._element).trigger(Event.HIDE)
|
||||
const hideEvent = $.Event(Event.HIDE)
|
||||
|
||||
$(this._element).trigger(hideEvent)
|
||||
if (hideEvent.isDefaultPrevented()) {
|
||||
return
|
||||
}
|
||||
|
||||
this._close()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user