1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-28 14:29:07 +02:00

Remove jQuery from alert.js and add .alert only if jQuery is available

This commit is contained in:
Johann-S
2017-08-23 12:03:50 +02:00
committed by XhmikosR
parent a3398fffd6
commit 2970d14dd9
5 changed files with 30 additions and 37 deletions

View File

@@ -85,8 +85,7 @@ class Alert {
let parent = false
if (selector) {
const tmpSelected = SelectorEngine.find(selector)
parent = tmpSelected[0]
parent = SelectorEngine.find(selector)[0]
}
if (!parent) {
@@ -136,16 +135,6 @@ class Alert {
}
})
}
static _handleDismiss(alertInstance) {
return function (event) {
if (event) {
event.preventDefault()
}
alertInstance.close(this)
}
}
}
/**
@@ -159,13 +148,17 @@ EventHandler.on(document, Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleD
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .alert to jQuery only if jQuery is present
*/
$.fn[NAME] = Alert._jQueryInterface
$.fn[NAME].Constructor = Alert
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT
return Alert._jQueryInterface
if (typeof window.$ !== 'undefined' || typeof window.jQuery !== 'undefined') {
const $ = window.$ || window.jQuery
$.fn[NAME] = Alert._jQueryInterface
$.fn[NAME].Constructor = Alert
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT
return Alert._jQueryInterface
}
}
export default Alert