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 GitHub
parent 0e91c6c502
commit e2df046eff

View File

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