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

[Float] handle resource Resource creation inside svg context #25599

Merged
merged 3 commits into from
Nov 1, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
assert that foreign object allows resources
  • Loading branch information
gnoff committed Nov 1, 2022
commit 6e949de028226e9887982c38caddc5bae1bab198
84 changes: 84 additions & 0 deletions packages/react-dom/src/__tests__/ReactDOMFloat-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5386,6 +5386,90 @@ describe('ReactDOMFloat', () => {
});

describe('resource free contexts', () => {
// @gate enableFloat
it('allows resources inside foreignobject within an svg context', async () => {
await actIntoEmptyDocument(() => {
const {pipe} = ReactDOMFizzServer.renderToPipeableStream(
<html>
<body>
<svg>
<foreignObject>
<title>foo</title>
</foreignObject>
</svg>
</body>
</html>,
);
pipe(writable);
});
expect(getMeaningfulChildren(document)).toEqual(
<html>
<head>
<title>foo</title>
</head>
<body>
<svg>
<foreignobject />
</svg>
</body>
</html>,
);

let root = ReactDOMClient.hydrateRoot(
document,
<html>
<body>
<svg>
<foreignObject>
<title>foo</title>
</foreignObject>
</svg>
</body>
</html>,
);
expect(Scheduler).toFlushWithoutYielding();
// @TODO the preload should not get inserted on hydration
expect(getMeaningfulChildren(document)).toEqual(
<html>
<head>
<title>foo</title>
</head>
<body>
<svg>
<foreignobject />
</svg>
</body>
</html>,
);

root.unmount();
root = ReactDOMClient.createRoot(document);
root.render(
<html>
<body>
<svg>
<foreignObject>
<title>foo</title>
</foreignObject>
</svg>
</body>
</html>,
);
expect(Scheduler).toFlushWithoutYielding();
expect(getMeaningfulChildren(document)).toEqual(
<html>
<head>
<title>foo</title>
</head>
<body>
<svg>
<foreignobject />
</svg>
</body>
</html>,
);
});

// @gate enableFloat
it('warns if you render something that is almost a resource inside an svg tree', async () => {
const root = ReactDOMClient.createRoot(container);
Expand Down