From 2cf4352e1c81a5b8c3528519a128c20e8e65531d Mon Sep 17 00:00:00 2001 From: Josh Story Date: Tue, 11 Oct 2022 08:42:42 -0700 Subject: [PATCH] Implement HostSingleton Fiber type (#25426) --- packages/react-art/src/ReactARTHostConfig.js | 1 + .../src/client/ReactDOMComponent.js | 10 +- .../src/client/ReactDOMComponentTree.js | 27 +- .../src/client/ReactDOMHostConfig.js | 354 ++++++- .../src/events/DOMPluginEventSystem.js | 23 +- .../events/plugins/EnterLeaveEventPlugin.js | 12 +- .../src/__tests__/ReactDOMFizzServer-test.js | 1 - .../src/__tests__/ReactDOMFloat-test.js | 67 +- .../src/__tests__/ReactDOMRoot-test.js | 23 +- .../ReactDOMSingletonComponents-test.js | 982 ++++++++++++++++++ .../src/__tests__/ReactRenderDocument-test.js | 38 +- .../src/__tests__/validateDOMNesting-test.js | 61 +- packages/react-dom/src/client/ReactDOMRoot.js | 8 +- .../DOMPluginEventSystem-test.internal.js | 11 +- .../src/test-utils/ReactTestUtils.js | 11 +- .../src/ReactFabricHostConfig.js | 1 + .../src/ReactNativeHostConfig.js | 1 + .../src/createReactNoop.js | 2 + .../react-reconciler/src/ReactFiber.new.js | 24 +- .../react-reconciler/src/ReactFiber.old.js | 24 +- .../src/ReactFiberBeginWork.new.js | 48 +- .../src/ReactFiberBeginWork.old.js | 48 +- .../src/ReactFiberCommitWork.new.js | 111 +- .../src/ReactFiberCommitWork.old.js | 111 +- .../src/ReactFiberCompleteWork.new.js | 67 +- .../src/ReactFiberCompleteWork.old.js | 67 +- .../src/ReactFiberComponentStack.js | 2 + .../ReactFiberHostConfigWithNoSingletons.js | 27 + .../src/ReactFiberHotReloading.new.js | 10 +- .../src/ReactFiberHotReloading.old.js | 10 +- .../src/ReactFiberHydrationContext.new.js | 80 +- .../src/ReactFiberHydrationContext.old.js | 80 +- .../src/ReactFiberReconciler.new.js | 2 + .../src/ReactFiberReconciler.old.js | 2 + .../src/ReactFiberTreeReflection.js | 19 +- .../src/ReactFiberUnwindWork.new.js | 3 + .../src/ReactFiberUnwindWork.old.js | 3 + .../src/ReactTestSelectors.js | 50 +- .../react-reconciler/src/ReactWorkTags.js | 4 +- .../src/forks/ReactFiberHostConfig.custom.js | 11 + .../src/getComponentNameFromFiber.js | 2 + .../src/ReactTestHostConfig.js | 1 + .../src/ReactTestRenderer.js | 9 +- packages/shared/ReactFeatureFlags.js | 5 +- .../forks/ReactFeatureFlags.native-fb.js | 1 + .../forks/ReactFeatureFlags.native-oss.js | 1 + .../forks/ReactFeatureFlags.test-renderer.js | 1 + .../ReactFeatureFlags.test-renderer.native.js | 1 + .../ReactFeatureFlags.test-renderer.www.js | 1 + .../shared/forks/ReactFeatureFlags.testing.js | 1 + .../forks/ReactFeatureFlags.testing.www.js | 1 + .../forks/ReactFeatureFlags.www-dynamic.js | 1 - .../shared/forks/ReactFeatureFlags.www.js | 1 + scripts/error-codes/codes.json | 7 +- 54 files changed, 2276 insertions(+), 193 deletions(-) create mode 100644 packages/react-dom/src/__tests__/ReactDOMSingletonComponents-test.js create mode 100644 packages/react-reconciler/src/ReactFiberHostConfigWithNoSingletons.js diff --git a/packages/react-art/src/ReactARTHostConfig.js b/packages/react-art/src/ReactARTHostConfig.js index aa3925cdbe817..9746fe055c44d 100644 --- a/packages/react-art/src/ReactARTHostConfig.js +++ b/packages/react-art/src/ReactARTHostConfig.js @@ -244,6 +244,7 @@ export * from 'react-reconciler/src/ReactFiberHostConfigWithNoScopes'; export * from 'react-reconciler/src/ReactFiberHostConfigWithNoTestSelectors'; export * from 'react-reconciler/src/ReactFiberHostConfigWithNoMicrotasks'; export * from 'react-reconciler/src/ReactFiberHostConfigWithNoResources'; +export * from 'react-reconciler/src/ReactFiberHostConfigWithNoSingletons'; export function appendInitialChild(parentInstance, child) { if (typeof child === 'string') { diff --git a/packages/react-dom-bindings/src/client/ReactDOMComponent.js b/packages/react-dom-bindings/src/client/ReactDOMComponent.js index 25e37d01c2210..fdcdf9801a218 100644 --- a/packages/react-dom-bindings/src/client/ReactDOMComponent.js +++ b/packages/react-dom-bindings/src/client/ReactDOMComponent.js @@ -73,6 +73,7 @@ import { enableTrustedTypesIntegration, enableCustomElementPropertySupport, enableClientRenderFallbackOnTextMismatch, + enableHostSingletons, } from 'shared/ReactFeatureFlags'; import { mediaEventTypes, @@ -312,12 +313,17 @@ function setInitialDOMProperties( // textContent on a