dillon1000/react

Commit

Add check for string and null 'rootElement' in ReactDOMFiber (#9869)

* Add check for string and null 'rootElement' in ReactDOMFiber

**what is the change?:**
Before we call 'rootElement.getAttribute' we check that the method is
defined.

**why make this change?:**
There is an internal use case I found where 'rootElement' is a string
and null at different points as the page is rendered.

It looks like this method was added as part of support for re-hydration
of server-side rendered content. I can't imagine we would want to reuse
content if the rootnode is a string or null. Not sure if we want an
earlier check that it's an element before this point.

**test plan:**
`yarn test`
and I manually tested this fix in the internal case where it was
breaking

* Add test and improve check for non-element rootElement

**what is the change?:**
We use the nodeType to check that we have the correct type of
rootElement, and we added a unit test.

**why make this change?:**
Improve this solution to the problem.

**test plan:**
`yarn test`

* run ./scripts/fiber/record-tests
Browse files
Changed paths3 files
First-parent comparison
M scripts/fiber/tests-passing.txt ModifiedM src/renderers/dom/fiber/ReactDOMFiber.js ModifiedM src/renderers/dom/shared/__tests__/ReactRenderDocument-test.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…