Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(js-ts): Convert app/util/browserScripts.js to TypeScript #11405

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions app/util/browserScripts.js → app/util/browserScripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,21 @@ export const JS_WINDOW_INFORMATION = `
export const JS_DESELECT_TEXT = `if (window.getSelection) {window.getSelection().removeAllRanges();}
else if (document.selection) {document.selection.empty();}`;

export const JS_POST_MESSAGE_TO_PROVIDER = (message, origin) => `(function () {
export const JS_POST_MESSAGE_TO_PROVIDER = (
message: object,
origin: string
) => `(function () {
try {
window.postMessage(${JSON.stringify(message)}, '${origin}');
} catch (e) {
//Nothing to do
}
})()`;

export const JS_IFRAME_POST_MESSAGE_TO_PROVIDER = (message, origin) =>
export const JS_IFRAME_POST_MESSAGE_TO_PROVIDER = (
_message: object,
_origin: string
) =>
`(function () {})()`;
/** Disable sending messages to iframes for now
*
Expand All @@ -93,7 +99,7 @@ export const JS_IFRAME_POST_MESSAGE_TO_PROVIDER = (message, origin) =>
for (let frame of iframes){

try {
frame.contentWindow.postMessage(${JSON.stringify(message)}, '${origin}');
frame.contentWindow.postMessage(${JSON.stringify(_message)}, '${_origin}');
} catch (e) {
//Nothing to do
}
Expand Down
Loading