Skip to content

Commit

Permalink
fix(ssr): check null _document.defaultView (#1337)
Browse files Browse the repository at this point in the history
  • Loading branch information
dodongphure committed Apr 4, 2021
1 parent 9f055d7 commit b43681c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/core/media-marshaller/print-hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,10 @@ export class PrintHook implements OnDestroy {

/** Teardown logic for the service. */
ngOnDestroy() {
this.beforePrintEventListeners.forEach(l => this._document.defaultView.removeEventListener('beforeprint', l));
this.afterPrintEventListeners.forEach(l => this._document.defaultView.removeEventListener('afterprint', l));
if (this._document.defaultView) {
this.beforePrintEventListeners.forEach(l => this._document.defaultView.removeEventListener('beforeprint', l));
this.afterPrintEventListeners.forEach(l => this._document.defaultView.removeEventListener('afterprint', l));
}
}

/** Is this service currently in Print-mode ? */
Expand Down

0 comments on commit b43681c

Please sign in to comment.