aboutsummaryrefslogtreecommitdiff
path: root/js/src/alert.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/alert.js')
-rw-r--r--js/src/alert.js29
1 files changed, 4 insertions, 25 deletions
diff --git a/js/src/alert.js b/js/src/alert.js
index 0bbe62af5..97b305138 100644
--- a/js/src/alert.js
+++ b/js/src/alert.js
@@ -1,17 +1,14 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.2): alert.js
+ * Bootstrap (v5.1.1): alert.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
-import {
- defineJQueryPlugin,
- getElementFromSelector,
- isDisabled
-} from './util/index'
+import { defineJQueryPlugin } from './util/index'
import EventHandler from './dom/event-handler'
import BaseComponent from './base-component'
+import { enableDismissTrigger } from './util/component-functions'
/**
* ------------------------------------------------------------------------
@@ -22,15 +19,9 @@ import BaseComponent from './base-component'
const NAME = 'alert'
const DATA_KEY = 'bs.alert'
const EVENT_KEY = `.${DATA_KEY}`
-const DATA_API_KEY = '.data-api'
-
-const SELECTOR_DISMISS = '[data-bs-dismiss="alert"]'
const EVENT_CLOSE = `close${EVENT_KEY}`
const EVENT_CLOSED = `closed${EVENT_KEY}`
-const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
-
-const CLASS_NAME_ALERT = 'alert'
const CLASS_NAME_FADE = 'fade'
const CLASS_NAME_SHOW = 'show'
@@ -94,19 +85,7 @@ class Alert extends BaseComponent {
* ------------------------------------------------------------------------
*/
-EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DISMISS, function (event) {
- if (['A', 'AREA'].includes(this.tagName)) {
- event.preventDefault()
- }
-
- if (isDisabled(this)) {
- return
- }
-
- const target = getElementFromSelector(this) || this.closest(`.${CLASS_NAME_ALERT}`)
- const alert = Alert.getOrCreateInstance(target)
- alert.close()
-})
+enableDismissTrigger(Alert, 'close')
/**
* ------------------------------------------------------------------------