34
import hasOwnProperty from 'shared/hasOwnProperty';
35
import {checkAttributeStringCoercion} from 'shared/CheckStringCoercion';
36
import {REACT_CONTEXT_TYPE} from 'shared/ReactSymbols';
37
-import {OffscreenComponent} from 'react-reconciler/src/ReactWorkTags';
37
38
export {
39
setCurrentUpdatePriority,
53
markNodeAsHoistable,
54
isOwnedInstance,
55
} from './ReactDOMComponentTree';
56
+import {traverseFragmentInstance} from 'react-reconciler/src/ReactFiberTreeReflection';
57
+
58
export {detachDeletedInstance};
59
import {hasRole} from './DOMAccessibilityRoles';
60
import {
2222
indexOfEventListener(listeners, type, listener, optionsOrUseCapture) === -1;
2223
if (isNewEventListener) {
2224
listeners.push({type, listener, optionsOrUseCapture});
2224
- traverseFragmentInstanceChildren(
2225
- this,
2226
- this._fragmentFiber.child,
2225
+ traverseFragmentInstance(
2226
+ this._fragmentFiber,
2227
addEventListenerToChild,
2228
type,
2229
listener,
2253
return;
2254
}
2255
if (typeof listeners !== 'undefined' && listeners.length > 0) {
2256
- traverseFragmentInstanceChildren(
2257
- this,
2258
- this._fragmentFiber.child,
2256
+ traverseFragmentInstance(
2257
+ this._fragmentFiber,
2258
removeEventListenerFromChild,
2259
type,
2260
listener,
2282
}
2283
// $FlowFixMe[prop-missing]
2284
FragmentInstance.prototype.focus = function (this: FragmentInstanceType) {
2286
- traverseFragmentInstanceChildren(
2287
- this,
2288
- this._fragmentFiber.child,
2289
- setFocusIfFocusable,
2290
- );
2285
+ traverseFragmentInstance(this._fragmentFiber, setFocusIfFocusable);
2286
};
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
-
2288
function normalizeListenerOptions(
2289
opts: ?EventListenerOptionsOrUseCapture,
2290
): string {