-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Fix iframe crash #4219
Fix iframe crash #4219
Conversation
🦋 Changeset detectedLatest commit: fdbcafc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🤔 One question that nags me is why do we throw an exception in Copying in @davidruisinger and @ianstormtaylor maybe you have some context I am missing |
…findDocumentOrShadowRoot-for-iframes
|
I'm assuming this issue only happens when the editor is rendered within a portal DOM element that is in an iframe? Would have been good to clarify 🙏 |
That is one of the issues yes (who knows what other usecases there are that fall into this category). In this case it's affecting the iframe example so https://www.slatejs.org/examples/iframe doesn't currently work (until this change is deployed). |
I was facing this issue in a different context.
This works because |
Description
Fixes iframe crashes
Context: The exception is thrown if an editor root element does not inherit from
Document
. However an document inside iframe will never inherit the same prototype aswindow.document
, this change prevents triggering this exception if we are inside an iframeIssue
Fixes: #4170
Example

Currently the iframe example crashes with the exception
Unable to find DocumentOrShadowRoot for editor element ...
With this change it works again:

Checks
yarn test
.yarn lint
. (Fix errors withyarn fix
.)yarn start
.)yarn changeset add
.)