File tree Expand file tree Collapse file tree 1 file changed +26
-16
lines changed Expand file tree Collapse file tree 1 file changed +26
-16
lines changed Original file line number Diff line number Diff line change @@ -122,32 +122,42 @@ function traverseAllChildrenImpl(
122
122
) {
123
123
var type = typeof children ;
124
124
125
- if ( type === 'undefined' || type === 'boolean' ) {
126
- // All of the above are perceived as null.
127
- children = null ;
128
- }
129
-
130
- if (
131
- children === null ||
132
- type === 'string' ||
133
- type === 'number' ||
134
- // The following is inlined from ReactElement. This means we can optimize
135
- // some checks. React Fiber also inlines this logic for similar purposes.
136
- ( type === 'object' && children . $$typeof === REACT_ELEMENT_TYPE ) ||
137
- ( type === 'object' && children . $$typeof === REACT_CALL_TYPE ) ||
138
- ( type === 'object' && children . $$typeof === REACT_RETURN_TYPE ) ||
139
- ( type === 'object' && children . $$typeof === REACT_PORTAL_TYPE )
140
- ) {
125
+ const invokeCallback = ( ) => {
141
126
callback (
142
127
traverseContext ,
143
128
children ,
144
129
// If it's the only child, treat the name as if it was wrapped in an array
145
130
// so that it's consistent if the number of children grows.
146
131
nameSoFar === '' ? SEPARATOR + getComponentKey ( children , 0 ) : nameSoFar ,
147
132
) ;
133
+ } ;
134
+
135
+ if ( type === 'undefined' || type === 'boolean' ) {
136
+ // All of the above are perceived as null.
137
+ children = null ;
138
+ }
139
+
140
+ if ( children === null ) {
141
+ invokeCallback ( ) ;
148
142
return 1 ;
149
143
}
150
144
145
+ switch ( type ) {
146
+ case 'string' :
147
+ case 'number' :
148
+ invokeCallback ( ) ;
149
+ return 1 ;
150
+ case 'object' :
151
+ switch ( children . $$typeof ) {
152
+ case REACT_ELEMENT_TYPE :
153
+ case REACT_CALL_TYPE :
154
+ case REACT_RETURN_TYPE :
155
+ case REACT_PORTAL_TYPE :
156
+ invokeCallback ( ) ;
157
+ return 1 ;
158
+ }
159
+ }
160
+
151
161
var child ;
152
162
var nextName ;
153
163
var subtreeCount = 0 ; // Count of children found in the current subtree.
You can’t perform that action at this time.
0 commit comments