mirror of https://github.com/twbs/bootstrap.git
Carousel: omit redundant checks as we are always transforming the right values
This commit is contained in:
parent
28f150d720
commit
88da704eed
|
@ -389,10 +389,6 @@ class Carousel extends BaseComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
_directionToOrder(direction) {
|
_directionToOrder(direction) {
|
||||||
if (![DIRECTION_RIGHT, DIRECTION_LEFT].includes(direction)) {
|
|
||||||
return direction
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isRTL()) {
|
if (isRTL()) {
|
||||||
return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT
|
return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT
|
||||||
}
|
}
|
||||||
|
@ -401,10 +397,6 @@ class Carousel extends BaseComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
_orderToDirection(order) {
|
_orderToDirection(order) {
|
||||||
if (![ORDER_NEXT, ORDER_PREV].includes(order)) {
|
|
||||||
return order
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isRTL()) {
|
if (isRTL()) {
|
||||||
return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT
|
return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT
|
||||||
}
|
}
|
||||||
|
|
|
@ -1200,9 +1200,7 @@ describe('Carousel', () => {
|
||||||
const carousel = new Carousel(carouselEl, {})
|
const carousel = new Carousel(carouselEl, {})
|
||||||
|
|
||||||
expect(carousel._directionToOrder('left')).toEqual('next')
|
expect(carousel._directionToOrder('left')).toEqual('next')
|
||||||
expect(carousel._directionToOrder('prev')).toEqual('prev')
|
|
||||||
expect(carousel._directionToOrder('right')).toEqual('prev')
|
expect(carousel._directionToOrder('right')).toEqual('prev')
|
||||||
expect(carousel._directionToOrder('next')).toEqual('next')
|
|
||||||
|
|
||||||
expect(carousel._orderToDirection('next')).toEqual('left')
|
expect(carousel._orderToDirection('next')).toEqual('left')
|
||||||
expect(carousel._orderToDirection('prev')).toEqual('right')
|
expect(carousel._orderToDirection('prev')).toEqual('right')
|
||||||
|
@ -1217,9 +1215,7 @@ describe('Carousel', () => {
|
||||||
expect(isRTL()).toBeTrue()
|
expect(isRTL()).toBeTrue()
|
||||||
|
|
||||||
expect(carousel._directionToOrder('left')).toEqual('prev')
|
expect(carousel._directionToOrder('left')).toEqual('prev')
|
||||||
expect(carousel._directionToOrder('prev')).toEqual('prev')
|
|
||||||
expect(carousel._directionToOrder('right')).toEqual('next')
|
expect(carousel._directionToOrder('right')).toEqual('next')
|
||||||
expect(carousel._directionToOrder('next')).toEqual('next')
|
|
||||||
|
|
||||||
expect(carousel._orderToDirection('next')).toEqual('right')
|
expect(carousel._orderToDirection('next')).toEqual('right')
|
||||||
expect(carousel._orderToDirection('prev')).toEqual('left')
|
expect(carousel._orderToDirection('prev')).toEqual('left')
|
||||||
|
|
Loading…
Reference in New Issue