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

Support document rendering #24523

Merged
merged 2 commits into from May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-dom/client.js
Expand Up @@ -23,7 +23,7 @@ import {
} from './';

export function createRoot(
container: Element | DocumentFragment,
container: Element | Document | DocumentFragment,
options?: CreateRootOptions,
): RootType {
if (__DEV__) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/ReactDOM.js
Expand Up @@ -148,7 +148,7 @@ const Internals = {
};

function createRoot(
container: Element | DocumentFragment,
container: Element | Document | DocumentFragment,
options?: CreateRootOptions,
): RootType {
if (__DEV__) {
Expand Down
5 changes: 2 additions & 3 deletions packages/react-dom/src/client/ReactDOMHostConfig.js
Expand Up @@ -672,9 +672,8 @@ export function clearContainer(container: Container): void {
if (container.nodeType === ELEMENT_NODE) {
((container: any): Element).textContent = '';
} else if (container.nodeType === DOCUMENT_NODE) {
const body = ((container: any): Document).body;
if (body != null) {
body.textContent = '';
if (container.documentElement) {
container.removeChild(container.documentElement);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/ReactDOMRoot.js
Expand Up @@ -164,7 +164,7 @@ ReactDOMHydrationRoot.prototype.unmount = ReactDOMRoot.prototype.unmount = funct
};

export function createRoot(
container: Element | DocumentFragment,
container: Element | Document | DocumentFragment,
options?: CreateRootOptions,
): RootType {
if (!isValidContainer(container)) {
Expand Down