diff options
author | GeoSot <geo.sotis@gmail.com> | 2021-07-28 17:39:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-28 17:39:32 +0300 |
commit | 4bfd8a2cbcb10610b4078cefa45756b4a96301a0 (patch) | |
tree | 2358a92299ff8fa105623932caacddbf8cd83a41 /js/src/toast.js | |
parent | 047145e8086793e7c39747e70f5d74a8860c2e50 (diff) |
Use a streamlined way to trigger component dismiss (#34170)
* use a streamlined way to trigger component dismiss
* add documentation
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
Diffstat (limited to 'js/src/toast.js')
-rw-r--r-- | js/src/toast.js | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/js/src/toast.js b/js/src/toast.js index 9b3c0f7c8b..bb5f768e6b 100644 --- a/js/src/toast.js +++ b/js/src/toast.js @@ -13,6 +13,7 @@ import { import EventHandler from './dom/event-handler' import Manipulator from './dom/manipulator' import BaseComponent from './base-component' +import { enableDismissTrigger } from './util/component-functions' /** * ------------------------------------------------------------------------ @@ -24,7 +25,6 @@ const NAME = 'toast' const DATA_KEY = 'bs.toast' const EVENT_KEY = `.${DATA_KEY}` -const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}` const EVENT_MOUSEOVER = `mouseover${EVENT_KEY}` const EVENT_MOUSEOUT = `mouseout${EVENT_KEY}` const EVENT_FOCUSIN = `focusin${EVENT_KEY}` @@ -51,8 +51,6 @@ const Default = { delay: 5000 } -const SELECTOR_DATA_DISMISS = '[data-bs-dismiss="toast"]' - /** * ------------------------------------------------------------------------ * Class Definition @@ -202,7 +200,6 @@ class Toast extends BaseComponent { } _setListeners() { - EventHandler.on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, () => this.hide()) EventHandler.on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true)) EventHandler.on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false)) EventHandler.on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true)) @@ -231,6 +228,8 @@ class Toast extends BaseComponent { } } +enableDismissTrigger(Toast) + /** * ------------------------------------------------------------------------ * jQuery |