Skip to content

Commit

Permalink
fix: add defensive checks
Browse files Browse the repository at this point in the history
  • Loading branch information
roberttaylor426 committed Jul 18, 2023
1 parent fe89c1d commit 30db8d8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Slider/Slider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,14 @@ const Slider = class Slider extends React.Component {

getSliderRef(el) {
this.sliderTrayElement = el;
// NOTE: we can't rely on the element itself to detect direction
// as the direction of the slider is currently flipped to ltr
this.rtl = window.getComputedStyle(el.closest('.carousel'), null).getPropertyValue('direction') === 'rtl';
if (el && window) {
// NOTE: we can't rely on the element itself to detect direction
// as the direction of the slider is currently flipped to ltr
const carouselElement = el.closest('.carousel');
if (carouselElement) {
this.rtl = window.getComputedStyle(carouselElement, null).getPropertyValue('direction') === 'rtl';
}
}
}


Expand Down

0 comments on commit 30db8d8

Please sign in to comment.