]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Clear timeout before showing the toast (#31155)
authorRohit Sharma <rohit2sharma95@gmail.com>
Sat, 11 Jul 2020 18:51:04 +0000 (00:21 +0530)
committerXhmikosR <xhmikosr@gmail.com>
Mon, 3 Aug 2020 16:06:36 +0000 (19:06 +0300)
* clear timeout before showing the toast

* Add unit test

* Remove the check for timeout

* Check for clearTimeout to have been called

Co-authored-by: XhmikosR <xhmikosr@gmail.com>
# Conflicts:
# js/tests/unit/toast.spec.js

js/src/toast.js

index 8da5069e96421c7877858a167426b70269e9bc17..93777683311199532db40930f4b887de23778941 100644 (file)
@@ -83,6 +83,8 @@ class Toast {
       return
     }
 
+    this._clearTimeout()
+
     if (this._config.animation) {
       this._element.classList.add(CLASS_NAME_FADE)
     }
@@ -130,8 +132,7 @@ class Toast {
   }
 
   dispose() {
-    clearTimeout(this._timeout)
-    this._timeout = null
+    this._clearTimeout()
 
     if (this._element.classList.contains(CLASS_NAME_SHOW)) {
       this._element.classList.remove(CLASS_NAME_SHOW)
@@ -184,6 +185,11 @@ class Toast {
     }
   }
 
+  _clearTimeout() {
+    clearTimeout(this._timeout)
+    this._timeout = null
+  }
+
   // Static
 
   static _jQueryInterface(config) {