Skip to content

Commit a94df2d

Browse files
committed
Merge branch 'master' of https://github.com/nolimits4web/swiper
2 parents 1cf24d4 + ced30cb commit a94df2d

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/core/loop/loopDestroy.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default function loopDestroy() {
22
const swiper = this;
33
const { params, slidesEl } = swiper;
4-
if (!params.loop || (swiper.virtual && swiper.params.virtual.enabled)) return;
4+
if (!params.loop || !slidesEl || (swiper.virtual && swiper.params.virtual.enabled)) return;
55
swiper.recalcSlides();
66

77
const newSlidesOrder = [];

src/swiper-element.mjs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ class SwiperContainer extends ClassToExtend {
147147
}
148148

149149
initialize() {
150-
if (this.initialized) return;
151-
this.initialized = true;
150+
if (this.swiper && this.swiper.initialized) return;
152151
const { params: swiperParams, passedParams } = getParams(this);
153152
this.swiperParams = swiperParams;
154153
this.passedParams = passedParams;
@@ -180,7 +179,8 @@ class SwiperContainer extends ClassToExtend {
180179

181180
connectedCallback() {
182181
if (
183-
this.initialized &&
182+
this.swiper &&
183+
this.swiper.initialized &&
184184
this.nested &&
185185
this.closest('swiper-slide') &&
186186
this.closest('swiper-slide').swiperLoopMoveDOM
@@ -204,7 +204,6 @@ class SwiperContainer extends ClassToExtend {
204204
if (this.swiper && this.swiper.destroy) {
205205
this.swiper.destroy();
206206
}
207-
this.initialized = false;
208207
}
209208

210209
updateSwiperOnPropChange(propName, propValue) {
@@ -238,7 +237,7 @@ class SwiperContainer extends ClassToExtend {
238237
}
239238

240239
attributeChangedCallback(attr, prevValue, newValue) {
241-
if (!this.initialized) return;
240+
if (!(this.swiper && this.swiper.initialized)) return;
242241
if (prevValue === 'true' && newValue === null) {
243242
newValue = false;
244243
}
@@ -269,7 +268,7 @@ paramsList.forEach((paramName) => {
269268
set(value) {
270269
if (!this.passedParams) this.passedParams = {};
271270
this.passedParams[paramName] = value;
272-
if (!this.initialized) return;
271+
if (!(this.swiper && this.swiper.initialized)) return;
273272
this.updateSwiperOnPropChange(paramName, value);
274273
},
275274
});

0 commit comments

Comments
 (0)