From d4de17b278b57760cfc9953d1da7892b44f0fc22 Mon Sep 17 00:00:00 2001 From: Vladimir Kharlampidi Date: Tue, 27 Feb 2024 14:31:03 +0300 Subject: [PATCH] fix(history): fix setting history in virtual slides fixes #7327 --- src/modules/history/history.mjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/history/history.mjs b/src/modules/history/history.mjs index 5304f481d..1e96b0632 100644 --- a/src/modules/history/history.mjs +++ b/src/modules/history/history.mjs @@ -50,7 +50,10 @@ export default function History({ swiper, extendParams, on }) { } else { location = window.location; } - const slide = swiper.slides[index]; + const slide = + swiper.virtual && swiper.params.virtual.enabled + ? swiper.slidesEl.querySelector(`[data-swiper-slide-index="${index}"]`) + : swiper.slides[index]; let value = slugify(slide.getAttribute('data-history')); if (swiper.params.history.root.length > 0) { let root = swiper.params.history.root;