Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
authorJohann-S <johann.servoire@gmail.com>2018-03-11 18:18:56 +0300
committerXhmikosR <xhmikosr@gmail.com>2019-02-20 23:05:45 +0300
commit7eddee286eb76da4d057a59706e4c512206dab45 (patch)
tree5319cd291c015fcec49e2af0cb1c890d0d966927 /js/src
parent0263d1742ce8ad25f0f2de30beebae69b2f55f10 (diff)
remove old references to jquery and some fixes
Diffstat (limited to 'js/src')
-rw-r--r--js/src/alert.js9
-rw-r--r--js/src/button.js5
-rw-r--r--js/src/carousel.js6
-rw-r--r--js/src/collapse.js17
-rw-r--r--js/src/dom/data.js4
-rw-r--r--js/src/dropdown.js2
-rw-r--r--js/src/index.js15
-rw-r--r--js/src/modal.js6
-rw-r--r--js/src/util.js6
9 files changed, 29 insertions, 41 deletions
diff --git a/js/src/alert.js b/js/src/alert.js
index 1bdd9706a4..9332aa891d 100644
--- a/js/src/alert.js
+++ b/js/src/alert.js
@@ -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
diff --git a/js/src/button.js b/js/src/button.js
index acba736af4..0e3b8a9df5 100644
--- a/js/src/button.js
+++ b/js/src/button.js
@@ -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
diff --git a/js/src/carousel.js b/js/src/carousel.js
index e33788594d..fd6d5bf802 100644
--- a/js/src/carousel.js
+++ b/js/src/carousel.js
@@ -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
diff --git a/js/src/collapse.js b/js/src/collapse.js
index 31200c33a8..7d6aa30ed8 100644
--- a/js/src/collapse.js
+++ b/js/src/collapse.js
@@ -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()
diff --git a/js/src/dom/data.js b/js/src/dom/data.js
index 82ff5eae83..4cee65d2b8 100644
--- a/js/src/dom/data.js
+++ b/js/src/dom/data.js
@@ -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') {
diff --git a/js/src/dropdown.js b/js/src/dropdown.js
index 85d8738e0d..ddc783c0dd 100644
--- a/js/src/dropdown.js
+++ b/js/src/dropdown.js
@@ -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
}
diff --git a/js/src/index.js b/js/src/index.js
index 665b889c55..327de242b2 100644
--- a/js/src/index.js
+++ b/js/src/index.js
@@ -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,
diff --git a/js/src/modal.js b/js/src/modal.js
index 898d1c73d7..6da3d25aa8 100644
--- a/js/src/modal.js
+++ b/js/src/modal.js
@@ -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)
}
}
diff --git a/js/src/util.js b/js/src/util.js
index 667f46076f..78f5fe3fbe 100644
--- a/js/src/util.js
+++ b/js/src/util.js
@@ -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