@@ -34,7 +34,6 @@ import {getCurrentRootHostContainer} from 'react-reconciler/src/ReactFiberHostCo
34
34
import hasOwnProperty from 'shared/hasOwnProperty' ;
35
35
import { checkAttributeStringCoercion } from 'shared/CheckStringCoercion' ;
36
36
import { REACT_CONTEXT_TYPE } from 'shared/ReactSymbols' ;
37
- import { OffscreenComponent } from 'react-reconciler/src/ReactWorkTags' ;
38
37
39
38
export {
40
39
setCurrentUpdatePriority ,
@@ -54,6 +53,8 @@ import {
54
53
markNodeAsHoistable ,
55
54
isOwnedInstance ,
56
55
} from './ReactDOMComponentTree' ;
56
+ import { traverseFragmentInstance } from 'react-reconciler/src/ReactFiberTreeReflection' ;
57
+
57
58
export { detachDeletedInstance } ;
58
59
import { hasRole } from './DOMAccessibilityRoles' ;
59
60
import {
@@ -2221,9 +2222,8 @@ FragmentInstance.prototype.addEventListener = function (
2221
2222
indexOfEventListener ( listeners , type , listener , optionsOrUseCapture ) === - 1 ;
2222
2223
if ( isNewEventListener ) {
2223
2224
listeners . push ( { type, listener, optionsOrUseCapture} ) ;
2224
- traverseFragmentInstanceChildren (
2225
- this ,
2226
- this . _fragmentFiber . child ,
2225
+ traverseFragmentInstance (
2226
+ this . _fragmentFiber ,
2227
2227
addEventListenerToChild ,
2228
2228
type ,
2229
2229
listener ,
@@ -2253,9 +2253,8 @@ FragmentInstance.prototype.removeEventListener = function (
2253
2253
return;
2254
2254
}
2255
2255
if ( typeof listeners !== 'undefined' && listeners . length > 0 ) {
2256
- traverseFragmentInstanceChildren (
2257
- this ,
2258
- this . _fragmentFiber . child ,
2256
+ traverseFragmentInstance (
2257
+ this . _fragmentFiber ,
2259
2258
removeEventListenerFromChild ,
2260
2259
type ,
2261
2260
listener ,
@@ -2283,45 +2282,9 @@ function removeEventListenerFromChild(
2283
2282
}
2284
2283
// $FlowFixMe[prop-missing]
2285
2284
FragmentInstance . prototype . focus = function ( this : FragmentInstanceType ) {
2286
- traverseFragmentInstanceChildren (
2287
- this ,
2288
- this . _fragmentFiber . child ,
2289
- setFocusIfFocusable ,
2290
- ) ;
2285
+ traverseFragmentInstance ( this . _fragmentFiber , setFocusIfFocusable ) ;
2291
2286
} ;
2292
2287
2293
- function traverseFragmentInstanceChildren < A , B , C > (
2294
- fragmentInstance : FragmentInstanceType ,
2295
- child : Fiber | null ,
2296
- fn : ( Instance , A , B , C ) => boolean ,
2297
- a : A ,
2298
- b : B ,
2299
- c : C ,
2300
- ) : void {
2301
- while ( child !== null ) {
2302
- if ( child . tag === HostComponent ) {
2303
- if ( fn ( child . stateNode , a , b , c ) ) {
2304
- return ;
2305
- }
2306
- } else if (
2307
- child . tag === OffscreenComponent &&
2308
- child . memoizedState !== null
2309
- ) {
2310
- // Skip hidden subtrees
2311
- } else {
2312
- traverseFragmentInstanceChildren (
2313
- fragmentInstance ,
2314
- child . child ,
2315
- fn ,
2316
- a ,
2317
- b ,
2318
- c ,
2319
- ) ;
2320
- }
2321
- child = child . sibling ;
2322
- }
2323
- }
2324
-
2325
2288
function normalizeListenerOptions (
2326
2289
opts : ?EventListenerOptionsOrUseCapture ,
2327
2290
) : string {
0 commit comments