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

Model Float on Hoistables semantics #26106

Merged
merged 10 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 9 additions & 9 deletions packages/react-devtools-shared/src/backend/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export function getInternalReactConstants(version: string): {
HostComponent: 5,
HostPortal: 4,
HostRoot: 3,
HostResource: 26, // In reality, 18.2+. But doesn't hurt to include it here
HostHoistable: 26, // In reality, 18.2+. But doesn't hurt to include it here
HostSingleton: 27, // Same as above
HostText: 6,
IncompleteClassComponent: 17,
Expand Down Expand Up @@ -257,7 +257,7 @@ export function getInternalReactConstants(version: string): {
HostComponent: 5,
HostPortal: 4,
HostRoot: 3,
HostResource: -1, // Doesn't exist yet
HostHoistable: -1, // Doesn't exist yet
HostSingleton: -1, // Doesn't exist yet
HostText: 6,
IncompleteClassComponent: 17,
Expand Down Expand Up @@ -290,7 +290,7 @@ export function getInternalReactConstants(version: string): {
HostComponent: 5,
HostPortal: 4,
HostRoot: 3,
HostResource: -1, // Doesn't exist yet
HostHoistable: -1, // Doesn't exist yet
HostSingleton: -1, // Doesn't exist yet
HostText: 6,
IncompleteClassComponent: 17,
Expand Down Expand Up @@ -323,7 +323,7 @@ export function getInternalReactConstants(version: string): {
HostComponent: 7,
HostPortal: 6,
HostRoot: 5,
HostResource: -1, // Doesn't exist yet
HostHoistable: -1, // Doesn't exist yet
HostSingleton: -1, // Doesn't exist yet
HostText: 8,
IncompleteClassComponent: -1, // Doesn't exist yet
Expand Down Expand Up @@ -356,7 +356,7 @@ export function getInternalReactConstants(version: string): {
HostComponent: 5,
HostPortal: 4,
HostRoot: 3,
HostResource: -1, // Doesn't exist yet
HostHoistable: -1, // Doesn't exist yet
HostSingleton: -1, // Doesn't exist yet
HostText: 6,
IncompleteClassComponent: -1, // Doesn't exist yet
Expand Down Expand Up @@ -397,7 +397,7 @@ export function getInternalReactConstants(version: string): {
IndeterminateComponent,
ForwardRef,
HostRoot,
HostResource,
HostHoistable,
HostSingleton,
HostComponent,
HostPortal,
Expand Down Expand Up @@ -465,7 +465,7 @@ export function getInternalReactConstants(version: string): {
return null;
case HostComponent:
case HostSingleton:
case HostResource:
case HostHoistable:
return type;
case HostPortal:
case HostText:
Expand Down Expand Up @@ -591,7 +591,7 @@ export function attach(
Fragment,
FunctionComponent,
HostRoot,
HostResource,
HostHoistable,
HostSingleton,
HostPortal,
HostComponent,
Expand Down Expand Up @@ -1032,7 +1032,7 @@ export function attach(
case HostRoot:
return ElementTypeRoot;
case HostComponent:
case HostResource:
case HostHoistable:
case HostSingleton:
return ElementTypeHostComponent;
case HostPortal:
Expand Down
2 changes: 1 addition & 1 deletion packages/react-devtools-shared/src/backend/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export type WorkTagMap = {
HostComponent: WorkTag,
HostPortal: WorkTag,
HostRoot: WorkTag,
HostResource: WorkTag,
HostHoistable: WorkTag,
HostSingleton: WorkTag,
HostText: WorkTag,
IncompleteClassComponent: WorkTag,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function InspectedElementStateTree({
}: Props): React.Node {
const {state, type} = inspectedElement;

// HostSingleton and HostResource may have state that we don't want to expose to users
// HostSingleton and HostHoistable may have state that we don't want to expose to users
const isHostComponent = type === ElementTypeHostComponent;

const entries = state != null ? Object.entries(state) : null;
Expand Down
16 changes: 7 additions & 9 deletions packages/react-dom-bindings/src/client/ReactDOMComponentTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @flow
*/

import type {FloatRoot, RootResources} from './ReactDOMFloatClient';
import type {HoistableRoot, RootResources} from './ReactDOMFloatClient';
import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
import type {ReactScopeInstance} from 'shared/ReactTypes';
import type {
Expand All @@ -24,7 +24,7 @@ import type {

import {
HostComponent,
HostResource,
HostHoistable,
HostSingleton,
HostText,
HostRoot,
Expand Down Expand Up @@ -178,7 +178,7 @@ export function getInstanceFromNode(node: Node): Fiber | null {
tag === HostComponent ||
tag === HostText ||
tag === SuspenseComponent ||
(enableFloat ? tag === HostResource : false) ||
(enableFloat ? tag === HostHoistable : false) ||
(enableHostSingletons ? tag === HostSingleton : false) ||
tag === HostRoot
) {
Expand All @@ -198,7 +198,7 @@ export function getNodeFromInstance(inst: Fiber): Instance | TextInstance {
const tag = inst.tag;
if (
tag === HostComponent ||
(enableFloat ? tag === HostResource : false) ||
(enableFloat ? tag === HostHoistable : false) ||
(enableHostSingletons ? tag === HostSingleton : false) ||
tag === HostText
) {
Expand Down Expand Up @@ -277,14 +277,12 @@ export function doesTargetHaveEventHandle(
return eventHandles.has(eventHandle);
}

export function getResourcesFromRoot(root: FloatRoot): RootResources {
export function getResourcesFromRoot(root: HoistableRoot): RootResources {
let resources = (root: any)[internalRootNodeResourcesKey];
if (!resources) {
resources = (root: any)[internalRootNodeResourcesKey] = {
styles: new Map(),
scripts: new Map(),
head: new Map(),
lastStructuredMeta: new Map(),
hoistableStyles: new Map(),
hoistableScripts: new Map(),
};
}
return resources;
Expand Down
Loading