Previously, we created an iframe to render the full document snapshot, as rrweb requires re-open()-ing the document (and dropping all event handlers, including the ones the preview uses).
Instead, we can use rrweb to just render the html element part of the document and do an innerHTML replacement of the result. This seems to work fine.
The only thing we need to do is a minor hack to ensure #storybook-root and #storybook-docs are always available, as the WebView assumes they are there and errors if they are not.
@shilman - perhaps we can either make the WebView more resilient, or even allow overriding the web view from a preset somehow (that might be tricky).
How to test
Include this canary in a project, check that you can render stories and run Chromatic builds.
Fixes AP-3900
What Changed
This is all from Tom's PR over from https://github.com/chromaui/archive-storybook/pull/14
Previously, we created an iframe to render the full document snapshot, as
rrweb
requires re-open()
-ing the document (and dropping all event handlers, including the ones the preview uses).Instead, we can use
rrweb
to just render thehtml
element part of the document and do aninnerHTML
replacement of the result. This seems to work fine.The only thing we need to do is a minor hack to ensure
#storybook-root
and#storybook-docs
are always available, as theWebView
assumes they are there and errors if they are not.@shilman - perhaps we can either make the
WebView
more resilient, or even allow overriding the web view from a preset somehow (that might be tricky).How to test
Include this canary in a project, check that you can render stories and run Chromatic builds.