diff options
author | Rohit Sharma <rohit2sharma95@gmail.com> | 2020-07-11 21:51:04 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2020-08-03 19:06:36 +0300 |
commit | f530ab7549e76a9faa5285edcd0d42ea8a30a6bf (patch) | |
tree | 63fc2d56b64b140921c1d3f9b7d210a9de7da7d7 | |
parent | 0ec2ce44b4c2dcf7c456dda0f78877d6a4a0540c (diff) |
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 <xhmikosr@gmail.com>
# Conflicts:
# js/tests/unit/toast.spec.js
-rw-r--r-- | js/src/toast.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/js/src/toast.js b/js/src/toast.js index 8da5069e96..9377768331 100644 --- a/js/src/toast.js +++ b/js/src/toast.js @@ -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) { |