Skip to content

Commit

Permalink
Merge pull request #18251 from nnnnoel/patch-3
Browse files Browse the repository at this point in the history
fix(chore): add type guard for globalWindow
  • Loading branch information
ndelangen authored Jul 6, 2022
2 parents 4dd5872 + 846d3fd commit 2d3cfe5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/channel-postmessage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export class PostmsgTransport {
constructor(private readonly config: Config) {
this.buffer = [];
this.handler = null;
globalWindow.addEventListener('message', this.handleEvent.bind(this), false);
if (globalWindow) {
globalWindow.addEventListener('message', this.handleEvent.bind(this), false);
}

// Check whether the config.page parameter has a valid value
if (config.page !== 'manager' && config.page !== 'preview') {
Expand Down

0 comments on commit 2d3cfe5

Please sign in to comment.