Skip to content

Commit

Permalink
Merge pull request #4141 from zakstucke/main
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister authored Sep 24, 2023
2 parents 64be3cb + b319cc6 commit b7629b0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compat/src/suspense.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function detachedClone(vnode, detachedParent, parentDom) {
}

function removeOriginal(vnode, detachedParent, originalParent) {
if (vnode) {
if (vnode && originalParent) {
vnode._original = null;
vnode._children =
vnode._children &&
Expand Down
26 changes: 26 additions & 0 deletions compat/test/browser/suspense.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2100,4 +2100,30 @@ describe('suspense', () => {
expect(scratch.innerHTML).to.eql(`<p>hello new world</p>`);
});
});

it('should not crash if fallback has same DOM as suspended nodes', () => {
const [Lazy, resolveLazy] = createLazy();

const App = () => {
const [, setTest] = useState(false);
useLayoutEffect(() => setTest(true), []);

return (
<Suspense fallback={<div />}>
<div>
<Lazy />
</div>
</Suspense>
);
};

render(<App />, scratch);
expect(scratch.innerHTML).to.equal('<div></div>');
rerender();

return resolveLazy(() => <p>hello world</p>).then(() => {
rerender();
expect(scratch.innerHTML).to.equal('<div><p>hello world</p></div>');
});
});
});

0 comments on commit b7629b0

Please sign in to comment.