-
Notifications
You must be signed in to change notification settings - Fork 1
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
fix: add global or import scripts into DOM #1030
base: main
Are you sure you want to change the base?
Conversation
Visit the preview URL for this PR (updated for commit 39974db): https://react-kitchen-sink-dev--pr1030-1027-add-global-and-mit9l9lq.web.app (expires Mon, 03 Mar 2025 13:13:52 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 6267897ade2ba783b6db70a53a60fc3946d625e9 |
|
const globalBlock = screen.global; | ||
const importedScripts = screen.importedScripts; | ||
|
||
const isScriptExist = document.getElementById("custom-scope-script"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be unique per screen.
`; | ||
|
||
if (isScriptExist) { | ||
isScriptExist.textContent = jsString; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not rerun the script, you need to remove the node and reinsert it.
if (has(invokableObj, "ensemble")) { | ||
const tempEnsemble = get(invokableObj, "ensemble") as { | ||
[key: string]: unknown; | ||
}; | ||
(window as unknown as InvokableWindow).ensemble = omitBy( | ||
tempEnsemble, | ||
isUndefined, | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be set once - most of the functions in ensemble API do not require any screen params. The only thing would be the modal context, which can be passed in as an argument.
|
||
return (scriptToExecute, context) => { | ||
with (context) { | ||
return eval('(' + scriptToExecute.toString() + ')()'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be scriptToExecute()
Describe your changes
Add global or import scripts into DOM to reduce the load on buildEvaluateFunction
Screenshots [Optional]
Issue ticket number and link
Closes #1027
Checklist before requesting a review
pnpm changeset add