Skip to content

Commit

Permalink
web: Check host before postMessage() and set config on initial load
Browse files Browse the repository at this point in the history
  • Loading branch information
laymonage committed Feb 26, 2023
1 parent 14fc00d commit 8ef2cf6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions web/src/giscus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export class GiscusWidget extends LitElement {
}

private sendMessage<T>(message: T) {
if (!this.iframeRef || !this.iframeRef.src.startsWith(this.host)) return;
this.iframeRef?.contentWindow?.postMessage({ giscus: message }, this.host);
}

Expand All @@ -242,9 +243,10 @@ export class GiscusWidget extends LitElement {
}

firstUpdated() {
this.iframeRef?.addEventListener('load', () =>
this.iframeRef?.classList.remove('loading')
);
this.iframeRef?.addEventListener('load', () => {
this.iframeRef?.classList.remove('loading');
this.updateConfig();
});
}

requestUpdate(
Expand Down

0 comments on commit 8ef2cf6

Please sign in to comment.