Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann-S <johann.servoire@gmail.com>2019-05-22 10:55:14 +0300
committerXhmikosR <xhmikosr@gmail.com>2019-05-30 11:58:34 +0300
commitc6dd1a7d93c9898a6444177eeaba0ede2448be9b (patch)
tree4cc8c414eba897ba10012e0a555ccde620701f1e /js/src/toast.js
parentfe777292b500d1658f3ab93bfa9550f1c334b162 (diff)
Backport #28777.
Toast should allow prevent default for hide and show events
Diffstat (limited to 'js/src/toast.js')
-rw-r--r--js/src/toast.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/js/src/toast.js b/js/src/toast.js
index 9657048469..fd023e7021 100644
--- a/js/src/toast.js
+++ b/js/src/toast.js
@@ -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()
}