Skip to content
Merged
Show file tree
Hide file tree
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
Disable legacy mode in Modern www builds
These already don't expose the entry points to create legacy roots.
  • Loading branch information
sebmarkbage committed Apr 3, 2024
commit 12ab8d6c121c0fa2a9eb00673f6509c651fbe495
4 changes: 2 additions & 2 deletions packages/react-dom/src/__tests__/findDOMNodeFB-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const ReactDOM = require('react-dom');
const StrictMode = React.StrictMode;

describe('findDOMNode', () => {
// @gate www
// @gate www && !disableLegacyMode
it('findDOMNode should return null if passed null', () => {
expect(ReactDOM.findDOMNode(null)).toBe(null);
});
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('findDOMNode', () => {
expect(b.tagName).toBe('SPAN');
});

// @gate www
// @gate www && !disableLegacyMode
it('findDOMNode should reject random objects', () => {
expect(function () {
ReactDOM.findDOMNode({foo: 'bar'});
Expand Down
60 changes: 38 additions & 22 deletions packages/react-reconciler/src/__tests__/ReactScope-test.internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ describe('ReactScope', () => {
});

// @gate www
it('DO_NOT_USE_queryAllNodes() works as intended', () => {
it('DO_NOT_USE_queryAllNodes() works as intended', async () => {
const testScopeQuery = (type, props) => true;
const TestScope = React.unstable_Scope;
const scopeRef = React.createRef();
Expand All @@ -417,20 +417,25 @@ describe('ReactScope', () => {
);
}

const renderer = ReactTestRenderer.create(<Test toggle={true} />, {
createNodeMock: element => {
return element;
},
});
let renderer;
await act(
() =>
(renderer = ReactTestRenderer.create(<Test toggle={true} />, {
createNodeMock: element => {
return element;
},
unstable_isConcurrent: true,
})),
);
let nodes = scopeRef.current.DO_NOT_USE_queryAllNodes(testScopeQuery);
expect(nodes).toEqual([divRef.current, spanRef.current, aRef.current]);
renderer.update(<Test toggle={false} />);
await act(() => renderer.update(<Test toggle={false} />));
nodes = scopeRef.current.DO_NOT_USE_queryAllNodes(testScopeQuery);
expect(nodes).toEqual([aRef.current, divRef.current, spanRef.current]);
});

// @gate www
it('DO_NOT_USE_queryFirstNode() works as intended', () => {
it('DO_NOT_USE_queryFirstNode() works as intended', async () => {
const testScopeQuery = (type, props) => true;
const TestScope = React.unstable_Scope;
const scopeRef = React.createRef();
Expand All @@ -454,20 +459,26 @@ describe('ReactScope', () => {
);
}

const renderer = ReactTestRenderer.create(<Test toggle={true} />, {
createNodeMock: element => {
return element;
},
});
let renderer;
await act(
() =>
(renderer = ReactTestRenderer.create(<Test toggle={true} />, {
createNodeMock: element => {
return element;
},
unstable_isConcurrent: true,
})),
);
let node = scopeRef.current.DO_NOT_USE_queryFirstNode(testScopeQuery);
expect(node).toEqual(divRef.current);
renderer.update(<Test toggle={false} />);
await act(() => renderer.update(<Test toggle={false} />));

node = scopeRef.current.DO_NOT_USE_queryFirstNode(testScopeQuery);
expect(node).toEqual(aRef.current);
});

// @gate www
it('containsNode() works as intended', () => {
it('containsNode() works as intended', async () => {
const TestScope = React.unstable_Scope;
const scopeRef = React.createRef();
const divRef = React.createRef();
Expand Down Expand Up @@ -500,23 +511,28 @@ describe('ReactScope', () => {
);
}

const renderer = ReactTestRenderer.create(<Test toggle={true} />, {
createNodeMock: element => {
return element;
},
});
let renderer;
await act(
() =>
(renderer = ReactTestRenderer.create(<Test toggle={true} />, {
createNodeMock: element => {
return element;
},
unstable_isConcurrent: true,
})),
);
expect(scopeRef.current.containsNode(divRef.current)).toBe(true);
expect(scopeRef.current.containsNode(spanRef.current)).toBe(true);
expect(scopeRef.current.containsNode(aRef.current)).toBe(true);
expect(scopeRef.current.containsNode(outerSpan.current)).toBe(false);
expect(scopeRef.current.containsNode(emRef.current)).toBe(false);
renderer.update(<Test toggle={false} />);
await act(() => renderer.update(<Test toggle={false} />));
expect(scopeRef.current.containsNode(divRef.current)).toBe(true);
expect(scopeRef.current.containsNode(spanRef.current)).toBe(true);
expect(scopeRef.current.containsNode(aRef.current)).toBe(true);
expect(scopeRef.current.containsNode(outerSpan.current)).toBe(false);
expect(scopeRef.current.containsNode(emRef.current)).toBe(true);
renderer.update(<Test toggle={true} />);
await act(() => renderer.update(<Test toggle={true} />));
expect(scopeRef.current.containsNode(emRef.current)).toBe(false);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ describe('ReactSuspense', () => {
expect(container.textContent).toEqual('AB');
});

// @gate forceConcurrentByDefaultForTesting
// @gate !disableLegacyMode && forceConcurrentByDefaultForTesting
it(
'interrupts current render when something suspends with a ' +
"delay and we've already skipped over a lower priority update in " +
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/forks/ReactFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const useModernStrictMode = true;
// because JSX is an extremely hot path.
export const disableStringRefs = false;

export const disableLegacyMode = false;
export const disableLegacyMode = __EXPERIMENTAL__;

export const disableDOMTestUtils = false;

Expand Down