diff options
| author | Johann-S <[email protected]> | 2018-03-05 15:40:23 +0100 |
|---|---|---|
| committer | XhmikosR <[email protected]> | 2019-02-20 22:05:45 +0200 |
| commit | 9744886519a834deba45b1cadbb0603ac2446102 (patch) | |
| tree | ca0b3f03ba69ae82fc91721e93ecb6cfd47b087e /js/src | |
| parent | 7f08061eca035d8f75651e9c3c32503e91f86fae (diff) | |
| download | bootstrap-9744886519a834deba45b1cadbb0603ac2446102.tar.xz bootstrap-9744886519a834deba45b1cadbb0603ac2446102.zip | |
upgrade to v4 stable
Diffstat (limited to 'js/src')
| -rw-r--r-- | js/src/carousel.js | 17 | ||||
| -rw-r--r-- | js/src/collapse.js | 13 |
2 files changed, 22 insertions, 8 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js index 4519d566c..e33788594 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -22,7 +22,6 @@ const VERSION = '4.3.1' const DATA_KEY = 'bs.carousel' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' -const JQUERY_NO_CONFLICT = $.fn[NAME] const ARROW_LEFT_KEYCODE = 37 // KeyboardEvent.which value for left arrow key const ARROW_RIGHT_KEYCODE = 39 // KeyboardEvent.which value for right arrow key const TOUCHEVENT_COMPAT_WAIT = 500 // Time for mouse compat events to fire after touch @@ -527,6 +526,7 @@ class Carousel { if (!data) { data = new Carousel(element, _config) + Data.setData(element, DATA_KEY, data) } if (typeof config === 'number') { @@ -602,13 +602,18 @@ EventHandler.on(window, Event.LOAD_DATA_API, () => { * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ + * add .carousel to jQuery only if jQuery is present */ -$.fn[NAME] = Carousel._jQueryInterface -$.fn[NAME].Constructor = Carousel -$.fn[NAME].noConflict = () => { - $.fn[NAME] = JQUERY_NO_CONFLICT - return Carousel._jQueryInterface +if (typeof window.$ !== 'undefined' || typeof window.jQuery !== 'undefined') { + const $ = window.$ || window.jQuery + const JQUERY_NO_CONFLICT = $.fn[NAME] + $.fn[NAME] = Carousel._jQueryInterface + $.fn[NAME].Constructor = Carousel + $.fn[NAME].noConflict = () => { + $.fn[NAME] = JQUERY_NO_CONFLICT + return Carousel._jQueryInterface + } } export default Carousel diff --git a/js/src/collapse.js b/js/src/collapse.js index 9da673cc9..31200c33a 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -142,7 +142,11 @@ class Collapse { } if (actives) { - activesData = Data.getData(actives[0], DATA_KEY) + const tempActiveData = actives.filter((elem) => { + const container = SelectorEngine.findOne(this._selector) + return !container.contains(elem) + }) + activesData = tempActiveData[0] ? Data.getData(tempActiveData[0], DATA_KEY) : null if (activesData && activesData._isTransitioning) { return } @@ -154,7 +158,12 @@ class Collapse { } if (actives) { - actives.forEach((elemActive) => Collapse._collapseInterface(elemActive, 'hide')) + actives.forEach((elemActive) => { + const container = SelectorEngine.findOne(this._selector) + if (!container.contains(elemActive)) { + Collapse._collapseInterface(elemActive, 'hide') + } + }) if (!activesData) { Data.setData(actives[0], DATA_KEY, null) } |
