Skip to content

Commit d64e660

Browse files
committed
Implement HostSingleton Fiber type
1 parent 5d60a0b commit d64e660

File tree

53 files changed

+1955
-146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1955
-146
lines changed

packages/react-art/src/ReactARTHostConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ export * from 'react-reconciler/src/ReactFiberHostConfigWithNoScopes';
244244
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoTestSelectors';
245245
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoMicrotasks';
246246
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoResources';
247+
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoSingletons';
247248

248249
export function appendInitialChild(parentInstance, child) {
249250
if (typeof child === 'string') {

packages/react-dom-bindings/src/client/ReactDOMComponent.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ function setInitialDOMProperties(
312312
// textContent on a <textarea> will cause the placeholder to not
313313
// show within the <textarea> until it has been focused and blurred again.
314314
// https://github.com/facebook/react/issues/6731#issuecomment-254874553
315-
const canSetTextContent = tag !== 'textarea' || nextProp !== '';
315+
const canSetTextContent =
316+
tag !== 'body' && (tag !== 'textarea' || nextProp !== '');
316317
if (canSetTextContent) {
317318
setTextContent(domElement, nextProp);
318319
}

packages/react-dom-bindings/src/client/ReactDOMComponentTree.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,19 @@ import type {
2525
import {
2626
HostComponent,
2727
HostResource,
28+
HostSingleton,
2829
HostText,
2930
HostRoot,
3031
SuspenseComponent,
3132
} from 'react-reconciler/src/ReactWorkTags';
3233

3334
import {getParentSuspenseInstance} from './ReactDOMHostConfig';
3435

35-
import {enableScopeAPI, enableFloat} from 'shared/ReactFeatureFlags';
36+
import {
37+
enableScopeAPI,
38+
enableFloat,
39+
enableHostSingletons,
40+
} from 'shared/ReactFeatureFlags';
3641

3742
const randomKey = Math.random()
3843
.toString(36)
@@ -169,12 +174,14 @@ export function getInstanceFromNode(node: Node): Fiber | null {
169174
(node: any)[internalInstanceKey] ||
170175
(node: any)[internalContainerInstanceKey];
171176
if (inst) {
177+
const tag = inst.tag;
172178
if (
173-
inst.tag === HostComponent ||
174-
inst.tag === HostText ||
175-
inst.tag === SuspenseComponent ||
176-
inst.tag === HostRoot ||
177-
(enableFloat ? inst.tag === HostResource : false)
179+
tag === HostComponent ||
180+
tag === HostText ||
181+
tag === SuspenseComponent ||
182+
tag === HostRoot ||
183+
(enableFloat ? tag === HostResource : false) ||
184+
(enableHostSingletons ? tag === HostSingleton : false)
178185
) {
179186
return inst;
180187
} else {
@@ -189,10 +196,12 @@ export function getInstanceFromNode(node: Node): Fiber | null {
189196
* DOM node.
190197
*/
191198
export function getNodeFromInstance(inst: Fiber): Instance | TextInstance {
199+
const tag = inst.tag;
192200
if (
193-
inst.tag === HostComponent ||
194-
inst.tag === HostText ||
195-
(enableFloat ? inst.tag === HostResource : false)
201+
tag === HostComponent ||
202+
tag === HostText ||
203+
(enableFloat ? tag === HostResource : false) ||
204+
(enableHostSingletons ? tag === HostSingleton : false)
196205
) {
197206
// In Fiber this, is just the state node right now. We assume it will be
198207
// a host component or host text.

0 commit comments

Comments
 (0)