Skip to content

Commit 5dfc485

Browse files
authored
fix tests for when float is off (#25839)
Some tests fail when float is off but when singletons are on. This PR makes some adjustments 1. 2 singleton tests assert float semantics so will fail. 2. the float dispatcher was being set on the server even when float was off. while the float calls didn't do anything warnings were still generated. Instead we provide an empty object for the dispatcher if float is off. Longer term the dispatcher should move to formatconfig and just reference the float methods if the flag is on 3. some external fizz runtime tests did not gate against float but should have
1 parent 827cbdb commit 5dfc485

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

packages/react-dom-bindings/src/server/ReactDOMFloatServer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export function setCurrentlyRenderingBoundaryResourcesTarget(
202202
resources.boundaryResources = boundaryResources;
203203
}
204204

205-
export const ReactDOMServerDispatcher = {
205+
export const ReactDOMServerFloatDispatcher = {
206206
preload,
207207
preinit,
208208
};

packages/react-dom-bindings/src/server/ReactDOMServerFormatConfig.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ import {
6969
resourcesFromElement,
7070
resourcesFromLink,
7171
resourcesFromScript,
72-
ReactDOMServerDispatcher,
72+
ReactDOMServerFloatDispatcher,
7373
} from './ReactDOMFloatServer';
7474
export {
7575
createResources,
@@ -89,6 +89,10 @@ import {
8989
import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals';
9090
const ReactDOMCurrentDispatcher = ReactDOMSharedInternals.Dispatcher;
9191

92+
const ReactDOMServerDispatcher = enableFloat
93+
? ReactDOMServerFloatDispatcher
94+
: {};
95+
9296
export function prepareToRender(resources: Resources): mixed {
9397
prepareToRenderResources(resources);
9498

packages/react-dom/src/__tests__/ReactDOMFloat-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ describe('ReactDOMFloat', () => {
608608
]);
609609
});
610610

611+
// @gate enableFloat
611612
it('dedupes if the external runtime is explicitly loaded using preinit', async () => {
612613
const unstable_externalRuntimeSrc = 'src-of-external-runtime';
613614
function App() {
@@ -5681,7 +5682,6 @@ describe('ReactDOMFloat', () => {
56815682
);
56825683
});
56835684

5684-
// @gate enableFloat
56855685
it('should not treat title descendants of svg into resources', async () => {
56865686
await actIntoEmptyDocument(() => {
56875687
const {pipe} = renderToPipeableStream(

packages/react-dom/src/__tests__/ReactDOMSingletonComponents-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ describe('ReactDOM HostSingleton', () => {
116116
: children;
117117
}
118118

119-
// @gate enableHostSingletons
119+
// @gate enableHostSingletons && enableFloat
120120
it('warns if you render the same singleton twice at the same time', async () => {
121121
const root = ReactDOMClient.createRoot(document);
122122
root.render(
@@ -201,7 +201,7 @@ describe('ReactDOM HostSingleton', () => {
201201
);
202202
});
203203

204-
// @gate enableHostSingletons
204+
// @gate enableHostSingletons && enableFloat
205205
it('renders into html, head, and body persistently so the node identities never change and extraneous styles are retained', async () => {
206206
gate(flags => {
207207
if (flags.enableHostSingletons !== true) {

0 commit comments

Comments
 (0)