mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
Merge isObject branches (#21226)
We assume that isArray and getIteratorFn are only called on objects. So we shouldn't have to check that again and again, and then check a flag. We can just stay in this branch. There is a slight semantic breakage here because you could have an iterator on a function, such as if it's a generator function. But that's not supported and that currently only works at the root. The inner slots don't support this. So this just makes it consistent.
This commit is contained in:
1 parent
d4cae99f2a
commit
39713716aa
2 files changed
+42
-50
No files matched your search
@@ -1231,9 +1231,7 @@ function ChildReconciler(shouldTrackSideEffects) {
|
||||
}
|
||||
|
||||
// Handle object types
|
||||
const isObject = typeof newChild === 'object' && newChild !== null;
|
||||
|
||||
if (isObject) {
|
||||
if (typeof newChild === 'object' && newChild !== null) {
|
||||
switch (newChild.$$typeof) {
|
||||
case REACT_ELEMENT_TYPE:
|
||||
return placeSingleChild(
|
||||
@@ -1266,6 +1264,26 @@ function ChildReconciler(shouldTrackSideEffects) {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isArray(newChild)) {
|
||||
return reconcileChildrenArray(
|
||||
returnFiber,
|
||||
currentFirstChild,
|
||||
newChild,
|
||||
lanes,
|
||||
);
|
||||
}
|
||||
|
||||
if (getIteratorFn(newChild)) {
|
||||
return reconcileChildrenIterator(
|
||||
returnFiber,
|
||||
currentFirstChild,
|
||||
newChild,
|
||||
lanes,
|
||||
);
|
||||
}
|
||||
|
||||
throwOnInvalidObjectType(returnFiber, newChild);
|
||||
}
|
||||
|
||||
if (typeof newChild === 'string' || typeof newChild === 'number') {
|
||||
@@ -1279,28 +1297,6 @@ function ChildReconciler(shouldTrackSideEffects) {
|
||||
);
|
||||
}
|
||||
|
||||
if (isArray(newChild)) {
|
||||
return reconcileChildrenArray(
|
||||
returnFiber,
|
||||
currentFirstChild,
|
||||
newChild,
|
||||
lanes,
|
||||
);
|
||||
}
|
||||
|
||||
if (getIteratorFn(newChild)) {
|
||||
return reconcileChildrenIterator(
|
||||
returnFiber,
|
||||
currentFirstChild,
|
||||
newChild,
|
||||
lanes,
|
||||
);
|
||||
}
|
||||
|
||||
if (isObject) {
|
||||
throwOnInvalidObjectType(returnFiber, newChild);
|
||||
}
|
||||
|
||||
if (__DEV__) {
|
||||
if (typeof newChild === 'function') {
|
||||
warnOnFunctionType(returnFiber);
|
||||
|
||||
@@ -1231,9 +1231,7 @@ function ChildReconciler(shouldTrackSideEffects) {
|
||||
}
|
||||
|
||||
// Handle object types
|
||||
const isObject = typeof newChild === 'object' && newChild !== null;
|
||||
|
||||
if (isObject) {
|
||||
if (typeof newChild === 'object' && newChild !== null) {
|
||||
switch (newChild.$$typeof) {
|
||||
case REACT_ELEMENT_TYPE:
|
||||
return placeSingleChild(
|
||||
@@ -1266,6 +1264,26 @@ function ChildReconciler(shouldTrackSideEffects) {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isArray(newChild)) {
|
||||
return reconcileChildrenArray(
|
||||
returnFiber,
|
||||
currentFirstChild,
|
||||
newChild,
|
||||
lanes,
|
||||
);
|
||||
}
|
||||
|
||||
if (getIteratorFn(newChild)) {
|
||||
return reconcileChildrenIterator(
|
||||
returnFiber,
|
||||
currentFirstChild,
|
||||
newChild,
|
||||
lanes,
|
||||
);
|
||||
}
|
||||
|
||||
throwOnInvalidObjectType(returnFiber, newChild);
|
||||
}
|
||||
|
||||
if (typeof newChild === 'string' || typeof newChild === 'number') {
|
||||
@@ -1279,28 +1297,6 @@ function ChildReconciler(shouldTrackSideEffects) {
|
||||
);
|
||||
}
|
||||
|
||||
if (isArray(newChild)) {
|
||||
return reconcileChildrenArray(
|
||||
returnFiber,
|
||||
currentFirstChild,
|
||||
newChild,
|
||||
lanes,
|
||||
);
|
||||
}
|
||||
|
||||
if (getIteratorFn(newChild)) {
|
||||
return reconcileChildrenIterator(
|
||||
returnFiber,
|
||||
currentFirstChild,
|
||||
newChild,
|
||||
lanes,
|
||||
);
|
||||
}
|
||||
|
||||
if (isObject) {
|
||||
throwOnInvalidObjectType(returnFiber, newChild);
|
||||
}
|
||||
|
||||
if (__DEV__) {
|
||||
if (typeof newChild === 'function') {
|
||||
warnOnFunctionType(returnFiber);
|
||||
|
||||
Reference in new issue
Block a user