Skip to content

Commit f530ab7

Browse files
Clear timeout before showing the toast (#31155)
* 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 <[email protected]> # Conflicts: # js/tests/unit/toast.spec.js
1 parent 0ec2ce4 commit f530ab7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

js/src/toast.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ class Toast {
8383
return
8484
}
8585

86+
this._clearTimeout()
87+
8688
if (this._config.animation) {
8789
this._element.classList.add(CLASS_NAME_FADE)
8890
}
@@ -130,8 +132,7 @@ class Toast {
130132
}
131133

132134
dispose() {
133-
clearTimeout(this._timeout)
134-
this._timeout = null
135+
this._clearTimeout()
135136

136137
if (this._element.classList.contains(CLASS_NAME_SHOW)) {
137138
this._element.classList.remove(CLASS_NAME_SHOW)
@@ -184,6 +185,11 @@ class Toast {
184185
}
185186
}
186187

188+
_clearTimeout() {
189+
clearTimeout(this._timeout)
190+
this._timeout = null
191+
}
192+
187193
// Static
188194

189195
static _jQueryInterface(config) {

0 commit comments

Comments
 (0)