Skip to content

Commit

Permalink
Ensure observer runs on browser only
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Nov 28, 2023
1 parent da60a0a commit 1356e7a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions projects/srm/src/app/page/page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,17 @@ export class PageComponent implements OnInit, AfterViewInit, OnDestroy {
}

ngAfterViewInit(): void {
this.surveyMutationObserver = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'childList') {
this.surveyVisible = (this.survey.nativeElement as HTMLElement).childElementCount > 0;
}
this.platform.browser(() => {
this.surveyMutationObserver = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'childList') {
this.surveyVisible = (this.survey.nativeElement as HTMLElement).childElementCount > 0;
}
});
});
this.surveyMutationObserver.observe(this.survey.nativeElement, {
childList: true,
});
});
this.surveyMutationObserver.observe(this.survey.nativeElement, {
childList: true,
});
}

Expand Down

0 comments on commit 1356e7a

Please sign in to comment.