-
Notifications
You must be signed in to change notification settings - Fork 47.1k
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
Fiber cannot render to DocumentFragment/ShadowRoot #11017
Comments
Hi, I have determined the same issue a few days ago. This might be related to The second note describes a fix to this problem. The method is getRootHostContext(rootContainerInstance) in the ReactFiberReconciler. If you apply this fix in the source and recompile, you will get another warning which says Warning: validateDOMNesting(...): cannot appear as a child of <#document>.
This issue needs more investigation, but the application itself should work on shadow-dom. Thanks, |
I have a fix in #11037. |
Note: there are more places in the source where we compare to |
Fix looks good @gaearon ! thx for super fast response :)
I think this check within getRootHostContext should be enough for WebComponents |
maybe also adding addition test for const template = document.createElement('template')
template.innerHTML = `<div>Render here</div>`
const templateInstance = template.content.cloneNode(true)
ReactDOM.render(React.createElement(HelloWorld), templateInstance); |
Would you like to contribute to the fixture I added? You can send a PR against my fork branch. You know more about web components than I do :-) |
Hi, the mentioned warning validateDOMNesting did only occur with the development bundle. I did forget to activate NODE_ENV = 'production'. Which tags to cover in a test might be a discussion for a dedicated thread because not only the tag but also the tag was introduced in the shadow DOM with V1. |
I fixed the warning too. |
huh I was AFK, next time sure ! thanks again @gaearon ! much appreciated 👍 |
React |
With 16.1.0-beta, render into document fragment works for me! Thanks! |
I am more than happy to confirm that with 16.1.0-beta everything works! thanks a lot @gaearon much appreciated. Cheers |
Do you want to request a feature or report a bug?
bug
What is the current behavior?
React 15.x was able to render within a DocumentFragment/shadowRoot, not possible with Fiber anymore
DEMO
https://www.webpackbin.com/bins/-KvPFG7-HGfQ34IgUxQt
related -> skatejs/renderer-react#3
What is the expected behavior?
be able to render to shadow root like previous versions of React
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React 16
Chrome
The text was updated successfully, but these errors were encountered: