Skip to content

Commit

Permalink
Fix not to read property of null
Browse files Browse the repository at this point in the history
100% reproduced issue
in my case
1. child sent connect message to parent
2. parent receives the message but this.iframe.contentWindow is null when parent closes child iframe before done with rendering
  • Loading branch information
robertKim authored and robertKim committed Feb 9, 2022
1 parent 0d4eba3 commit 77e2641
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Bellhop.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ export class Bellhop extends BellhopEventDispatcher {

// Be polite and respond to the child that we're ready
if (!this.isChild) {
// Timing issue: this.iframe.contentWindow is null when parent closes child iframe before done with rendering
if (!this.target) {
return;
}
this.target.postMessage(message, this.origin);
}

Expand Down

0 comments on commit 77e2641

Please sign in to comment.