]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Carousel: omit redundant checks as we are always transforming the right values
authorGeoSot <geo.sotis@gmail.com>
Wed, 9 Mar 2022 22:38:17 +0000 (00:38 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Thu, 10 Mar 2022 13:22:14 +0000 (15:22 +0200)
js/src/carousel.js
js/tests/unit/carousel.spec.js

index 37ebde3fcc17472263e22fd83ef527cd112c7efd..70c5fd286a08f440d6d0597c4ad7123db58b9639 100644 (file)
@@ -389,10 +389,6 @@ class Carousel extends BaseComponent {
   }
 
   _directionToOrder(direction) {
-    if (![DIRECTION_RIGHT, DIRECTION_LEFT].includes(direction)) {
-      return direction
-    }
-
     if (isRTL()) {
       return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT
     }
@@ -401,10 +397,6 @@ class Carousel extends BaseComponent {
   }
 
   _orderToDirection(order) {
-    if (![ORDER_NEXT, ORDER_PREV].includes(order)) {
-      return order
-    }
-
     if (isRTL()) {
       return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT
     }
index d6320debf023f5d6c9e5e36fe8f41f783d8f4868..536a60e27191d21ca2f2d10fd2ce5b5b4307cf7b 100644 (file)
@@ -1200,9 +1200,7 @@ describe('Carousel', () => {
       const carousel = new Carousel(carouselEl, {})
 
       expect(carousel._directionToOrder('left')).toEqual('next')
-      expect(carousel._directionToOrder('prev')).toEqual('prev')
       expect(carousel._directionToOrder('right')).toEqual('prev')
-      expect(carousel._directionToOrder('next')).toEqual('next')
 
       expect(carousel._orderToDirection('next')).toEqual('left')
       expect(carousel._orderToDirection('prev')).toEqual('right')
@@ -1217,9 +1215,7 @@ describe('Carousel', () => {
       expect(isRTL()).toBeTrue()
 
       expect(carousel._directionToOrder('left')).toEqual('prev')
-      expect(carousel._directionToOrder('prev')).toEqual('prev')
       expect(carousel._directionToOrder('right')).toEqual('next')
-      expect(carousel._directionToOrder('next')).toEqual('next')
 
       expect(carousel._orderToDirection('next')).toEqual('right')
       expect(carousel._orderToDirection('prev')).toEqual('left')