From 7cffedef190c6e75bf84adfa6dfddd64e1bfa0e6 Mon Sep 17 00:00:00 2001 From: Vladimir Kharlampidi Date: Mon, 15 Jul 2024 17:40:04 +0700 Subject: [PATCH] fix(element): fix observer to watch for slides fixes #7598 --- src/core/modules/observer/observer.mjs | 4 ++-- src/swiper-element.mjs | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/core/modules/observer/observer.mjs b/src/core/modules/observer/observer.mjs index c8acf3271..d50c61ed9 100644 --- a/src/core/modules/observer/observer.mjs +++ b/src/core/modules/observer/observer.mjs @@ -26,10 +26,10 @@ export default function Observer({ swiper, extendParams, on, emit }) { window.setTimeout(observerUpdate, 0); } }); - observer.observe(target, { attributes: typeof options.attributes === 'undefined' ? true : options.attributes, - childList: typeof options.childList === 'undefined' ? true : options.childList, + childList: + swiper.isElement || (typeof options.childList === 'undefined' ? true : options).childList, characterData: typeof options.characterData === 'undefined' ? true : options.characterData, }); diff --git a/src/swiper-element.mjs b/src/swiper-element.mjs index c207c7c34..5624df620 100644 --- a/src/swiper-element.mjs +++ b/src/swiper-element.mjs @@ -158,9 +158,7 @@ class SwiperContainer extends ClassToExtend { // eslint-disable-next-line this.swiper = new Swiper(this.shadowRoot.querySelector('.swiper'), { - ...(swiperParams.virtual - ? {} - : { observer: true, observeSlideChildren: this.slideSlots > 0 }), + ...(swiperParams.virtual ? {} : { observer: true }), ...swiperParams, touchEventsTarget: 'container', onAny: (name, ...args) => {