]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Carousel: change class check as it can only exist if carousel is sliding
authorGeoSot <geo.sotis@gmail.com>
Thu, 10 Mar 2022 00:12:19 +0000 (02:12 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Thu, 10 Mar 2022 13:22:14 +0000 (15:22 +0200)
Also, fix the corresponding test

js/src/carousel.js
js/tests/unit/carousel.spec.js

index 5a9b2dc84627bc3c2344234ba70d94be66aa5b90..7a30beb10e3d9355845668cd59a8e2cf5e514f1b 100644 (file)
@@ -59,7 +59,6 @@ const SELECTOR_ACTIVE = '.active'
 const SELECTOR_ITEM = '.carousel-item'
 const SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM
 const SELECTOR_ITEM_IMG = '.carousel-item img'
-const SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev'
 const SELECTOR_INDICATORS = '.carousel-indicators'
 const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]'
 const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]'
@@ -142,7 +141,7 @@ class Carousel extends BaseComponent {
       this._stayPaused = true
     }
 
-    if (SelectorEngine.findOne(SELECTOR_NEXT_PREV, this._element)) {
+    if (this._isSliding) {
       triggerTransitionEnd(this._element)
       this.cycle(true)
     }
index 9817b83f1c6e9945d1835d9334a90134f7df4f53..8875f3f00382c5a68d2f77bcc6eb308099228806 100644 (file)
@@ -868,7 +868,7 @@ describe('Carousel', () => {
   })
 
   describe('pause', () => {
-    it('should call cycle if the carousel have carousel-item-next and carousel-item-prev class', () => {
+    it('should call cycle if the carousel have carousel-item-next or carousel-item-prev class, cause is sliding', () => {
       fixtureEl.innerHTML = [
         '<div id="myCarousel" class="carousel slide">',
         '  <div class="carousel-inner">',
@@ -887,6 +887,7 @@ describe('Carousel', () => {
       spyOn(carousel, 'cycle')
       spyOn(carousel, '_clearInterval')
 
+      carousel._slide('next')
       carousel.pause()
 
       expect(carousel.cycle).toHaveBeenCalledWith(true)