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

Not working when "produce()" object across iframes #766

Closed
atvoid opened this issue Mar 15, 2021 · 2 comments
Closed

Not working when "produce()" object across iframes #766

atvoid opened this issue Mar 15, 2021 · 2 comments

Comments

@atvoid
Copy link
Contributor

atvoid commented Mar 15, 2021

When we have multiple iframes with the same origin, we can share objects between different iframe window. But immer produce has a check isPlainObject(), there is a condition "Object.getPrototype(xxx) === Object.prototype", which makes this scenario broken. Because the window.Object.prototype in different iframes have different instances. This condition will return false.

The basic repro example is:

in iframe, we can set window.parent.test = {a: 1} (this can work when iframe and parent have same origin)
in parent window, we can access window.test and produce(window.test, (draft) => { } ), but this action will get exception "Not a plain object"

Can we change the condition "Object.getPrototype(xxx) === Object.prototype" in the function isPlainObject() ?

@atvoid atvoid changed the title Not working when produce object across iframes Produce is not working when produce object across iframes Mar 15, 2021
@atvoid atvoid changed the title Produce is not working when produce object across iframes Not working when produce object across iframes Mar 15, 2021
@atvoid atvoid changed the title Not working when produce object across iframes Not working when "produce()" object across iframes Mar 15, 2021
@mweststrate
Copy link
Collaborator

Feel free to verify whether your solution or the one mentioned here works and submit a PR :)

@mweststrate
Copy link
Collaborator

🎉 This issue has been resolved in version 8.0.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

No branches or pull requests

2 participants