Skip to content

Commit 5d68327

Browse files
author
Dennis Lemm
committed
add optional chaining to slider
1 parent 60540d7 commit 5d68327

File tree

1 file changed

+4
-2
lines changed
  • templates/theme-default/assets/js/components

1 file changed

+4
-2
lines changed

templates/theme-default/assets/js/components/slider.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,12 @@ function init(el) {
183183

184184
function getNextSlide(direction = 1) {
185185
let next =
186-
direction > 0 ? activeSlide.nextElementSibling || activeSlide : activeSlide.previousElementSibling || activeSlide;
186+
direction > 0
187+
? activeSlide?.nextElementSibling || activeSlide
188+
: activeSlide?.previousElementSibling || activeSlide;
187189

188190
for (let i = 1; i < slidesPerGroup; i++) {
189-
next = direction > 0 ? next.nextElementSibling || next : next.previousElementSibling || next;
191+
next = direction > 0 ? next?.nextElementSibling || next : next?.previousElementSibling || next;
190192
}
191193

192194
return next;

0 commit comments

Comments
 (0)