Skip to content

Commit

Permalink
Implement HostSingleton Fiber type
Browse files Browse the repository at this point in the history
  • Loading branch information
gnoff committed Oct 6, 2022
1 parent 5d60a0b commit d64e660
Show file tree
Hide file tree
Showing 53 changed files with 1,955 additions and 146 deletions.
1 change: 1 addition & 0 deletions packages/react-art/src/ReactARTHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
3 changes: 2 additions & 1 deletion packages/react-dom-bindings/src/client/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ function setInitialDOMProperties(
// textContent on a <textarea> will cause the placeholder to not
// show within the <textarea> until it has been focused and blurred again.
// https://github.com/facebook/react/issues/6731#issuecomment-254874553
const canSetTextContent = tag !== 'textarea' || nextProp !== '';
const canSetTextContent =
tag !== 'body' && (tag !== 'textarea' || nextProp !== '');
if (canSetTextContent) {
setTextContent(domElement, nextProp);
}
Expand Down
27 changes: 18 additions & 9 deletions packages/react-dom-bindings/src/client/ReactDOMComponentTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@ import type {
import {
HostComponent,
HostResource,
HostSingleton,
HostText,
HostRoot,
SuspenseComponent,
} from 'react-reconciler/src/ReactWorkTags';

import {getParentSuspenseInstance} from './ReactDOMHostConfig';

import {enableScopeAPI, enableFloat} from 'shared/ReactFeatureFlags';
import {
enableScopeAPI,
enableFloat,
enableHostSingletons,
} from 'shared/ReactFeatureFlags';

const randomKey = Math.random()
.toString(36)
Expand Down Expand Up @@ -169,12 +174,14 @@ export function getInstanceFromNode(node: Node): Fiber | null {
(node: any)[internalInstanceKey] ||
(node: any)[internalContainerInstanceKey];
if (inst) {
const tag = inst.tag;
if (
inst.tag === HostComponent ||
inst.tag === HostText ||
inst.tag === SuspenseComponent ||
inst.tag === HostRoot ||
(enableFloat ? inst.tag === HostResource : false)
tag === HostComponent ||
tag === HostText ||
tag === SuspenseComponent ||
tag === HostRoot ||
(enableFloat ? tag === HostResource : false) ||
(enableHostSingletons ? tag === HostSingleton : false)
) {
return inst;
} else {
Expand All @@ -189,10 +196,12 @@ export function getInstanceFromNode(node: Node): Fiber | null {
* DOM node.
*/
export function getNodeFromInstance(inst: Fiber): Instance | TextInstance {
const tag = inst.tag;
if (
inst.tag === HostComponent ||
inst.tag === HostText ||
(enableFloat ? inst.tag === HostResource : false)
tag === HostComponent ||
tag === HostText ||
(enableFloat ? tag === HostResource : false) ||
(enableHostSingletons ? tag === HostSingleton : false)
) {
// In Fiber this, is just the state node right now. We assume it will be
// a host component or host text.
Expand Down
Loading

0 comments on commit d64e660

Please sign in to comment.