Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit b43681c

Browse files
authored
fix(ssr): check null _document.defaultView (#1337)
1 parent 9f055d7 commit b43681c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/lib/core/media-marshaller/print-hook.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,10 @@ export class PrintHook implements OnDestroy {
224224

225225
/** Teardown logic for the service. */
226226
ngOnDestroy() {
227-
this.beforePrintEventListeners.forEach(l => this._document.defaultView.removeEventListener('beforeprint', l));
228-
this.afterPrintEventListeners.forEach(l => this._document.defaultView.removeEventListener('afterprint', l));
227+
if (this._document.defaultView) {
228+
this.beforePrintEventListeners.forEach(l => this._document.defaultView.removeEventListener('beforeprint', l));
229+
this.afterPrintEventListeners.forEach(l => this._document.defaultView.removeEventListener('afterprint', l));
230+
}
229231
}
230232

231233
/** Is this service currently in Print-mode ? */

0 commit comments

Comments
 (0)