mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-16 18:17:31 +08:00
fix(slides): check that mutation observer is defined for ssr (#20791)
This commit is contained in:
@ -132,16 +132,19 @@ export class Slides implements ComponentInterface {
|
||||
@Event() ionSlideTouchEnd!: EventEmitter<void>;
|
||||
|
||||
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() {
|
||||
|
Reference in New Issue
Block a user