mirror of
https://github.com/twbs/bootstrap.git
synced 2025-09-28 22:39:11 +02:00
remove old references to jquery and some fixes
This commit is contained in:
@@ -114,8 +114,11 @@ class Alert {
|
||||
}
|
||||
|
||||
_destroyElement(element) {
|
||||
if (element.parentNode) {
|
||||
element.parentNode.removeChild(element)
|
||||
}
|
||||
|
||||
EventHandler.trigger(element, Event.CLOSED)
|
||||
element.parentNode.removeChild(element)
|
||||
}
|
||||
|
||||
// Static
|
||||
@@ -150,8 +153,8 @@ EventHandler.on(document, Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleD
|
||||
* add .alert to jQuery only if jQuery is present
|
||||
*/
|
||||
|
||||
if (typeof window.$ !== 'undefined' || typeof window.jQuery !== 'undefined') {
|
||||
const $ = window.$ || window.jQuery
|
||||
const $ = Util.jQuery
|
||||
if (typeof $ !== 'undefined') {
|
||||
const JQUERY_NO_CONFLICT = $.fn[NAME]
|
||||
$.fn[NAME] = Alert._jQueryInterface
|
||||
$.fn[NAME].Constructor = Alert
|
||||
|
@@ -9,6 +9,7 @@ import Data from './dom/data'
|
||||
import EventHandler from './dom/eventHandler'
|
||||
import Manipulator from './dom/manipulator'
|
||||
import SelectorEngine from './dom/selectorEngine'
|
||||
import Util from './util'
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
@@ -175,8 +176,8 @@ EventHandler.on(document, Event.BLUR_DATA_API, Selector.DATA_TOGGLE_CARROT, (eve
|
||||
* add .button to jQuery only if jQuery is present
|
||||
*/
|
||||
|
||||
if (typeof window.$ !== 'undefined' || typeof window.jQuery !== 'undefined') {
|
||||
const $ = window.$ || window.jQuery
|
||||
const $ = Util.jQuery
|
||||
if (typeof $ !== 'undefined') {
|
||||
const JQUERY_NO_CONFLICT = $.fn[NAME]
|
||||
$.fn[NAME] = Button._jQueryInterface
|
||||
$.fn[NAME].Constructor = Button
|
||||
|
@@ -571,7 +571,7 @@ class Carousel {
|
||||
config.interval = false
|
||||
}
|
||||
|
||||
Carousel._jQueryInterface.call($(target), config)
|
||||
Carousel._carouselInterface(target, config)
|
||||
|
||||
if (slideIndex) {
|
||||
Data.getData(target, DATA_KEY).to(slideIndex)
|
||||
@@ -605,8 +605,8 @@ EventHandler.on(window, Event.LOAD_DATA_API, () => {
|
||||
* add .carousel to jQuery only if jQuery is present
|
||||
*/
|
||||
|
||||
if (typeof window.$ !== 'undefined' || typeof window.jQuery !== 'undefined') {
|
||||
const $ = window.$ || window.jQuery
|
||||
const $ = Util.jQuery
|
||||
if (typeof $ !== 'undefined') {
|
||||
const JQUERY_NO_CONFLICT = $.fn[NAME]
|
||||
$.fn[NAME] = Carousel._jQueryInterface
|
||||
$.fn[NAME].Constructor = Carousel
|
||||
|
@@ -141,12 +141,11 @@ class Collapse {
|
||||
}
|
||||
}
|
||||
|
||||
const container = SelectorEngine.findOne(this._selector)
|
||||
if (actives) {
|
||||
const tempActiveData = actives.filter((elem) => {
|
||||
const container = SelectorEngine.findOne(this._selector)
|
||||
return !container.contains(elem)
|
||||
})
|
||||
const tempActiveData = actives.filter((elem) => container !== elem)
|
||||
activesData = tempActiveData[0] ? Data.getData(tempActiveData[0], DATA_KEY) : null
|
||||
|
||||
if (activesData && activesData._isTransitioning) {
|
||||
return
|
||||
}
|
||||
@@ -159,14 +158,14 @@ class Collapse {
|
||||
|
||||
if (actives) {
|
||||
actives.forEach((elemActive) => {
|
||||
const container = SelectorEngine.findOne(this._selector)
|
||||
if (!container.contains(elemActive)) {
|
||||
if (container !== elemActive) {
|
||||
Collapse._collapseInterface(elemActive, 'hide')
|
||||
}
|
||||
|
||||
if (!activesData) {
|
||||
Data.setData(elemActive, DATA_KEY, null)
|
||||
}
|
||||
})
|
||||
if (!activesData) {
|
||||
Data.setData(actives[0], DATA_KEY, null)
|
||||
}
|
||||
}
|
||||
|
||||
const dimension = this._getDimension()
|
||||
|
@@ -23,10 +23,10 @@ const Data = (() => {
|
||||
key,
|
||||
id
|
||||
}
|
||||
id++
|
||||
}
|
||||
|
||||
storeData[id] = data
|
||||
id++
|
||||
storeData[element.key.id] = data
|
||||
},
|
||||
get(element, key) {
|
||||
if (typeof element === 'undefined' || typeof element.key === 'undefined') {
|
||||
|
@@ -460,7 +460,7 @@ class Dropdown {
|
||||
if (/input|textarea/i.test(event.target.tagName)
|
||||
? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE &&
|
||||
(event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE ||
|
||||
$(event.target).closest(Selector.MENU).length) : !REGEXP_KEYDOWN.test(event.which)) {
|
||||
SelectorEngine.closest(event.target, Selector.MENU)) : !REGEXP_KEYDOWN.test(event.which)) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -17,21 +17,6 @@ import Util from './util'
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
(() => {
|
||||
// only check jQuery version if jQuery is available
|
||||
if (typeof window.$ !== 'undefined' || typeof window.jQuery !== 'undefined') {
|
||||
const version = window.$.fn.jquery.split(' ')[0].split('.')
|
||||
const minMajor = 1
|
||||
const ltMajor = 2
|
||||
const minMinor = 9
|
||||
const minPatch = 1
|
||||
const maxMajor = 4
|
||||
|
||||
if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
|
||||
throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0')
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
||||
export {
|
||||
Util,
|
||||
|
@@ -232,7 +232,7 @@ class Modal {
|
||||
}
|
||||
|
||||
_showElement(relatedTarget) {
|
||||
const transition = $(this._element).hasClass(ClassName.FADE)
|
||||
const transition = this._element.classList.contains(ClassName.FADE)
|
||||
|
||||
if (!this._element.parentNode ||
|
||||
this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
|
||||
@@ -295,14 +295,14 @@ class Modal {
|
||||
|
||||
_setEscapeEvent() {
|
||||
if (this._isShown && this._config.keyboard) {
|
||||
$(this._element).on(Event.KEYDOWN_DISMISS, (event) => {
|
||||
EventHandler.on(this._element, Event.KEYDOWN_DISMISS, (event) => {
|
||||
if (event.which === ESCAPE_KEYCODE) {
|
||||
event.preventDefault()
|
||||
this.hide()
|
||||
}
|
||||
})
|
||||
} else if (!this._isShown) {
|
||||
$(this._element).off(Event.KEYDOWN_DISMISS)
|
||||
EventHandler.off(this._element, Event.KEYDOWN_DISMISS)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -69,8 +69,8 @@ const Util = {
|
||||
}
|
||||
|
||||
// Get transition-duration of the element
|
||||
let transitionDuration = element.style.transitionDuration
|
||||
let transitionDelay = element.style.transitionDelay
|
||||
let transitionDuration = window.getComputedStyle(element).transitionDuration
|
||||
let transitionDelay = window.getComputedStyle(element).transitionDelay
|
||||
|
||||
const floatTransitionDuration = parseFloat(transitionDuration)
|
||||
const floatTransitionDelay = parseFloat(transitionDelay)
|
||||
@@ -92,7 +92,7 @@ const Util = {
|
||||
},
|
||||
|
||||
triggerTransitionEnd(element) {
|
||||
EventHandler.trigger(element, Util.TRANSITION_END)
|
||||
element.dispatchEvent(new Event(Util.TRANSITION_END))
|
||||
},
|
||||
|
||||
// TODO: Remove in v5
|
||||
|
Reference in New Issue
Block a user