Skip to content

Commit 7562b89

Browse files
committed
More window -> globalThis
1 parent c2ab73b commit 7562b89

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

examples/widget/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
function parseFragment() {
18-
const fragmentString = window.location.hash || "?";
18+
const fragmentString = globalThis.location.hash || "?";
1919
return new URLSearchParams(fragmentString.substring(Math.max(fragmentString.indexOf("?"), 0)));
2020
}
2121

src/transport/PostmessageTransport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export class PostmessageTransport extends EventEmitter implements ITransport {
159159
if (this.stopController.signal.aborted) return;
160160
if (!ev.data) return; // invalid event
161161

162-
if (this.strictOriginCheck && ev.origin !== window.origin) return; // bad origin
162+
if (this.strictOriginCheck && ev.origin !== globalThis.origin) return; // bad origin
163163

164164
// treat the message as a response first, then downgrade to a request
165165
const response = <IWidgetApiResponse>ev.data;

test/WidgetApi-test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ describe("WidgetApi", () => {
100100

101101
const response = clientTrafficHelper.nextQueuedResponse();
102102
if (response) {
103-
window.postMessage(
103+
globalThis.postMessage(
104104
{
105105
...request,
106106
response: response,
@@ -109,14 +109,14 @@ describe("WidgetApi", () => {
109109
);
110110
}
111111
};
112-
window.addEventListener("message", clientListener);
112+
globalThis.addEventListener("message", clientListener);
113113

114114
widgetApi = new WidgetApi("WidgetApi-test", "*");
115115
widgetApi.start();
116116
});
117117

118118
afterEach(() => {
119-
window.removeEventListener("message", clientListener);
119+
globalThis.removeEventListener("message", clientListener);
120120
});
121121

122122
describe("readEventRelations", () => {

0 commit comments

Comments
 (0)