fix(slides): check that mutation observer is defined for ssr (#20791)

This commit is contained in:
Brandy Carney
2020-03-16 17:36:58 -04:00
committed by Liam DeBeasi
parent e24060ecd9
commit 2d5d2515be

View File

@ -132,6 +132,8 @@ export class Slides implements ComponentInterface {
@Event() ionSlideTouchEnd!: EventEmitter<void>;
connectedCallback() {
// tslint:disable-next-line: strict-type-predicates
if (typeof MutationObserver !== 'undefined') {
const mut = this.mutationO = new MutationObserver(() => {
if (this.swiperReady) {
this.update();
@ -143,6 +145,7 @@ export class Slides implements ComponentInterface {
});
this.el.componentOnReady().then(() => this.initSwiper());
}
}
async disconnectedCallback() {
if (this.mutationO) {