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

window事件 和 document.write失效 #49

Closed
yiludege opened this issue Aug 11, 2022 · 4 comments
Closed

window事件 和 document.write失效 #49

yiludege opened this issue Aug 11, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@yiludege
Copy link
Collaborator

描述bug
window上的事件比如onload 和 document.write添加 script 标签无法生效

@yiludege yiludege added the bug Something isn't working label Aug 11, 2022
@jk4235
Copy link

jk4235 commented Aug 12, 2022

我看了下,现在是把子应用的window.onxxx直接指向主应用的window.onxxx

这样多个子应用同时用到window.onxxx的话会有问题,没有隔离

为什么不直接挂在iframeWindow上呢?

此外可能需要在mount和unmount的时候手动处理一些事件了

@yiludege
Copy link
Collaborator Author

@jk4235

不管挂哪里都是有问题的,比如:挂在 iframeWindow.onload上,iframe 是一开始就准备好的,子应用的 js 是 iframe ready 后注入的也就是说 js 里面的 window.onload 事件永远都不会触发,这个地方估计要框架维护一个针对 load 事件、domContentLoaded事件之类的事件列表,进行手动触发。

当然框架也提供了 plugin:windowAddEventListenerHook、windowPropertyOverride,用户可以自行 diy 这个地方

@jk4235
Copy link

jk4235 commented Aug 12, 2022

这个地方估计要框架维护一个针对 load 事件、domContentLoaded事件之类的事件列表,进行手动触发。

对,我的意思就是直接挂在iframeWindow上,然后手动在对应的生命周期里invoke,避免多个子应用互相干扰

@yiludege
Copy link
Collaborator Author

明白,这个地方如果有兴趣可以 pr,我估计没这么快

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants