ryanseddon / react-frame-component

Render your React app to an iFrame
http://ryanseddon.github.io/react-frame-component/
MIT License
1.75k stars 156 forks source link

Add document.write() fallback #248

Open andrewpye opened 1 year ago

andrewpye commented 1 year ago

As per https://github.com/ryanseddon/react-frame-component/issues/169#issuecomment-1769738677, this PR adds a new dangerouslyUseDocWrite prop to the Frame component as an "escape hatch" that allows consumers to fall back to using document.write() to populate the frame's initial content. This is usually not advisable, but some libraries such as Recaptcha and Google Maps will only work with certain values of the frame's location and/or origin, and the current srcdoc approach for initial content population is incompatible with these libraries.

andrewpye commented 1 year ago

Thanks for the input on this @ryanseddon 🙇 We've got a couple of heavy projects on the go at the moment so this has been sidelined whilst those are underway. I hope to return to it once they're shipped so we can wrap this up 🤞

IvanKalinin commented 2 months ago

@andrewpye @ryanseddon Seems like removing the done callback is fixing the test, because the test is not async anymore, because document.write() is synchronous (v4 tests did not have the callback at all). I guess removing done() and the .only() directive should allow us to move forward.