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

用户自定义的生命周期方法没有在沙箱内执行 #72

Open
asiainfoliwei opened this issue Nov 25, 2021 · 4 comments
Open

用户自定义的生命周期方法没有在沙箱内执行 #72

asiainfoliwei opened this issue Nov 25, 2021 · 4 comments

Comments

@asiainfoliwei
Copy link

image
如上图,当子应用生命周期方法有调用全局对象,直接访问的也是全局的对象

@yisar
Copy link
Collaborator

yisar commented Nov 25, 2021

感觉这块不需要在沙箱里运行,比如 mount 一般是 Fre.render(<App/>, document.getElementById("root")) 这里的 document 必须是全局 document

@asiainfoliwei
Copy link
Author

感觉这块不需要在沙箱里运行,比如 mount 一般是 Fre.render(<App/>, document.getElementById("root")) 这里的 document 必须是全局 document

我提一个case呀,如果在生命周期里面需要访问子应用其他js之前定义的全局对象,是不是就访问不到了,第二个是
image
我看example都是主动把shadowdom root 传进去,如果生命周期函数也在沙箱里面执行的话是不是就可以改造是不是就可以小一点,proxy劫持domcument -> shadowdom root, 如果需要访问原始docuemnt可以在allowList加一个rowDocument

@yisar
Copy link
Collaborator

yisar commented Nov 25, 2021

proxy劫持domcument -> shadowdom root

这个是不现实的,document 和 shadow root 不是一个东西,我们之前也打算直接代理到沙雕上,但是 react 和 vue 这种框架对 document 的依赖比想象中的更多

fre 是可以的,因为 fre 只用了几个 document 的方法

你可以尝试一下,如果你能搞定的话,欢迎 pr

@asiainfoliwei
Copy link
Author

我理解不用全部方法,把get dom节点的方法hack一份,就可以了,我看micro-app这边已经在用了
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants