From 2d5d2515be86496a280d93847185ab332e5d47a2 Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Mon, 16 Mar 2020 17:36:58 -0400 Subject: [PATCH] fix(slides): check that mutation observer is defined for ssr (#20791) --- core/src/components/slides/slides.tsx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/core/src/components/slides/slides.tsx b/core/src/components/slides/slides.tsx index 4159adfd19..d162c4371a 100644 --- a/core/src/components/slides/slides.tsx +++ b/core/src/components/slides/slides.tsx @@ -132,16 +132,19 @@ export class Slides implements ComponentInterface { @Event() ionSlideTouchEnd!: EventEmitter; connectedCallback() { - const mut = this.mutationO = new MutationObserver(() => { - if (this.swiperReady) { - this.update(); - } - }); - mut.observe(this.el, { - childList: true, - subtree: true - }); - this.el.componentOnReady().then(() => this.initSwiper()); + // tslint:disable-next-line: strict-type-predicates + if (typeof MutationObserver !== 'undefined') { + const mut = this.mutationO = new MutationObserver(() => { + if (this.swiperReady) { + this.update(); + } + }); + mut.observe(this.el, { + childList: true, + subtree: true + }); + this.el.componentOnReady().then(() => this.initSwiper()); + } } async disconnectedCallback() {