-
Notifications
You must be signed in to change notification settings - Fork 443
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
Iframe Javascript URLs #122
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/builder-io/partytown/J75Mt7U2yuPjQ8bptouywxPBqmPB |
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.
Awesome job! Love the you added a test too. Only thing is to see about not using getter()
, which will do a call to main. But if we have the src
value already on the web worker we may be able to avoid that. Thanks
src/lib/web-worker/worker-iframe.ts
Outdated
@@ -35,10 +35,18 @@ export const patchHTMLIFrameElement = (WorkerHTMLIFrameElement: any, env: WebWor | |||
|
|||
src: { | |||
get() { | |||
let src = getIframeEnv(this).$location$.href; | |||
let src = getter(this, ['src']); |
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.
Is there a way to do this without using getter()
which is doing a call to the main thread? Could you try using getInstanceStateValue()
and setInstanceStateValue()
value instead so the value stays on the worker thread? The anchor element does something like this: https://github.com/BuilderIO/partytown/blob/1e2fac14760895e8e6d8624236ae550b584b2995/src/lib/web-worker/worker-anchor.ts#L14
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.
Thanks for that 🙏 I just used getInstanceStateValue()
and setInstanceStateValue()
to avoid calls to the main thread
src/lib/web-worker/worker-node.ts
Outdated
@@ -69,6 +69,11 @@ export const createNodeCstr = ( | |||
if (isIFrame) { | |||
// an iframe element's instanceId is also | |||
// the winId of its contentWindow | |||
const src = getter(newNode, ['src']); |
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.
Same comment as before, and try to avoid using getter()
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.
Using getInstanceStateValue()
now
src/lib/types.ts
Outdated
@@ -524,6 +524,7 @@ export const enum NodeName { | |||
export const enum StateProp { | |||
errorHandlers = 'error', | |||
loadHandlers = 'load', | |||
src = 'src', |
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.
Is this guy ok or should it be a number?
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.
A number would be fine.
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.
Thanks, just updated it :)
f88fe2c
to
53d17b5
Compare
* using getInstanceStateValue() instead of getter() * using setInstanceStateValue() instead of setter()
20fadd5
to
10d5ffe
Compare
awesome thanks! |
This MR allows us to execute scripts from Javascript URLs