nuxt / devtools

Unleash Nuxt Developer Experience
https://devtools.nuxt.com
MIT License
2.85k stars 153 forks source link

Useless line #583

Closed ManUtopiK closed 7 months ago

ManUtopiK commented 7 months ago

This line do nothing. It can be removed.

https://github.com/nuxt/devtools/blob/f3c3de1d95ba5da08dd665c2918500b309adb2af/packages/devtools/src/runtime/plugins/view/client.ts#L270

syncClient tell the iframe to set the client at https://github.com/nuxt/devtools/blob/f3c3de1d95ba5da08dd665c2918500b309adb2af/packages/devtools/src/runtime/plugins/view/client.ts#L116 But at this point of the mounting process, the iframe isn't even present in the DOM. The iframe will be appended to the body and mounted just after.

This syncClient function will be called by the getIframe() function here : https://github.com/nuxt/devtools/blob/f3c3de1d95ba5da08dd665c2918500b309adb2af/packages/devtools/src/runtime/plugins/view/client.ts#L124 Or by the open() function. Note that this function trigger twice syncClient. You can put a console.trace(client, iframe) line 112 to see that.

Removing this line 270 has no impact.

The mounting process is quite complex but really clever. I didn't know this way of iframe communication. However, this is working only on same domain. By the way, I just want to know if you have planned a refactoring to use a postMessage communication or something similar that allow to communicate between different domains ? Thanks.