@office-iss/react-native-win32 0.81.2 → 0.82.0-preview.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.flowconfig +3 -11
- package/CHANGELOG.json +118 -43
- package/CHANGELOG.md +45 -27
- package/IntegrationTests/IntegrationTestsApp.js +2 -2
- package/IntegrationTests/LayoutEventsTest.js +3 -3
- package/Libraries/ActionSheetIOS/ActionSheetIOS.js +7 -3
- package/Libraries/Alert/RCTAlertManager.android.js +4 -2
- package/Libraries/Animated/Animated.d.ts +2 -0
- package/Libraries/Animated/AnimatedEvent.js +1 -1
- package/Libraries/Animated/AnimatedExports.js.flow +1 -0
- package/Libraries/Animated/AnimatedImplementation.js +4 -2
- package/Libraries/Animated/AnimatedMock.js +1 -1
- package/Libraries/Animated/Easing.js +2 -0
- package/Libraries/Animated/NativeAnimatedAllowlist.js +1 -0
- package/Libraries/Animated/animations/Animation.js +19 -20
- package/Libraries/Animated/animations/TimingAnimation.js +2 -0
- package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
- package/Libraries/Animated/components/AnimatedSectionList.js +1 -1
- package/Libraries/Animated/nodes/AnimatedColor.js +9 -9
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +4 -4
- package/Libraries/Animated/nodes/AnimatedNode.js +14 -7
- package/Libraries/Animated/nodes/AnimatedObject.js +7 -7
- package/Libraries/Animated/nodes/AnimatedProps.js +32 -32
- package/Libraries/Animated/nodes/AnimatedStyle.js +23 -21
- package/Libraries/Animated/nodes/AnimatedTransform.js +6 -6
- package/Libraries/Animated/nodes/AnimatedValue.js +18 -26
- package/Libraries/AppState/AppState.js +8 -4
- package/Libraries/BatchedBridge/BatchedBridge.js +1 -0
- package/Libraries/BatchedBridge/MessageQueue.js +5 -0
- package/Libraries/BatchedBridge/NativeModules.js +1 -1
- package/Libraries/Blob/BlobManager.js +1 -1
- package/Libraries/Blob/URLSearchParams.js +2 -0
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +2 -2
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +2 -2
- package/Libraries/Components/Button.js +1 -1
- package/Libraries/Components/Button.win32.js +1 -1
- package/Libraries/Components/Pressable/Pressable.js +10 -1
- package/Libraries/Components/Pressable/Pressable.win32.js +9 -0
- package/Libraries/Components/Pressable/useAndroidRippleForView.js +2 -2
- package/Libraries/Components/ScrollView/ScrollView.js +13 -4
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
- package/Libraries/Components/StatusBar/StatusBar.js +2 -2
- package/Libraries/Components/Switch/Switch.js +1 -1
- package/Libraries/Components/TextInput/TextInput.flow.js +12 -5
- package/Libraries/Components/TextInput/TextInput.flow.win32.js +12 -5
- package/Libraries/Components/TextInput/TextInput.js +14 -5
- package/Libraries/Components/TextInput/TextInput.win32.js +15 -7
- package/Libraries/Components/TextInput/TextInputState.js +1 -1
- package/Libraries/Components/TextInput/TextInputState.win32.js +1 -1
- package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +2 -3
- package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
- package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -1
- package/Libraries/Components/Touchable/TouchableOpacity.js +1 -1
- package/Libraries/Components/Touchable/TouchableWin32.js +1 -1
- package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +3 -3
- package/Libraries/Components/View/View.js +81 -167
- package/Libraries/Components/View/View.win32.js +3 -1
- package/Libraries/Core/Devtools/loadBundleFromServer.js +1 -1
- package/Libraries/Core/Devtools/loadBundleFromServer.win32.js +1 -1
- package/Libraries/Core/ExceptionsManager.js +4 -2
- package/Libraries/Core/ReactFiberErrorDialog.js +3 -3
- package/Libraries/Core/ReactNativeVersion.js +37 -10
- package/Libraries/Core/Timers/JSTimers.js +4 -1
- package/Libraries/Core/Timers/NativeTiming.js +1 -0
- package/Libraries/Core/Timers/immediateShim.js +2 -1
- package/Libraries/Core/Timers/queueMicrotask.js +1 -0
- package/Libraries/Core/setUpPerformance.js +3 -4
- package/Libraries/Debugging/DebuggingOverlayRegistry.js +5 -3
- package/Libraries/Image/Image.android.js +327 -111
- package/Libraries/Image/Image.ios.js +6 -1
- package/Libraries/Image/Image.win32.js +6 -1
- package/Libraries/Image/ImageSourceUtils.js +8 -2
- package/Libraries/Image/assetPaths.js +1 -1
- package/Libraries/Image/resolveAssetSource.js +1 -1
- package/Libraries/Image/resolveAssetSource.win32.js +6 -7
- package/Libraries/Interaction/InteractionManager.js +118 -167
- package/Libraries/Interaction/PanResponder.js +7 -52
- package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -0
- package/Libraries/Lists/FlatList.js +5 -6
- package/Libraries/LogBox/Data/LogBoxData.js +5 -2
- package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +2 -2
- package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.win32.js +1 -1
- package/Libraries/Modal/Modal.js +3 -3
- package/Libraries/NativeComponent/NativeComponentRegistry.js +1 -1
- package/Libraries/NativeComponent/ViewConfig.js +2 -2
- package/Libraries/Network/RCTNetworking.android.js +1 -1
- package/Libraries/Network/RCTNetworking.ios.js +1 -1
- package/Libraries/Network/RCTNetworking.win32.js +1 -1
- package/Libraries/Network/XMLHttpRequest.js +20 -5
- package/Libraries/Network/convertRequestBody.js +1 -1
- package/Libraries/PermissionsAndroid/PermissionsAndroid.js +10 -9
- package/Libraries/Pressability/HoverState.js +2 -0
- package/Libraries/Pressability/HoverState.win32.js +2 -0
- package/Libraries/Pressability/Pressability.js +1 -1
- package/Libraries/Pressability/Pressability.win32.js +1 -1
- package/Libraries/PushNotificationIOS/PushNotificationIOS.js +2 -2
- package/Libraries/ReactNative/AppRegistryImpl.js +4 -2
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +2 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +3 -3
- package/Libraries/ReactNative/RendererImplementation.js +116 -116
- package/Libraries/ReactNative/UIManager.js +3 -3
- package/Libraries/ReactNative/renderApplication.js +1 -0
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -1
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +38 -35
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +51 -22
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +54 -24
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +36 -33
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +5 -5
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +5 -5
- package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -1
- package/Libraries/Share/Share.js +4 -0
- package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +2 -2
- package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +2 -2
- package/Libraries/StyleSheet/PlatformColorValueTypes.win32.js +4 -0
- package/Libraries/StyleSheet/StyleSheet.d.ts +7 -22
- package/Libraries/StyleSheet/StyleSheetExports.js +2 -8
- package/Libraries/StyleSheet/StyleSheetExports.js.flow +11 -18
- package/Libraries/StyleSheet/flattenStyle.js +2 -2
- package/Libraries/StyleSheet/processAspectRatio.js +2 -0
- package/Libraries/StyleSheet/processFilter.js +5 -5
- package/Libraries/StyleSheet/splitLayoutProps.js +2 -2
- package/Libraries/Text/Text.js +534 -234
- package/Libraries/Text/Text.win32.js +647 -274
- package/Libraries/Text/TextNativeComponent.js +2 -2
- package/Libraries/Text/TextNativeComponent.win32.js +2 -2
- package/Libraries/Utilities/Appearance.d.ts +3 -5
- package/Libraries/Utilities/Appearance.js +5 -17
- package/Libraries/Utilities/HMRClient.js +2 -1
- package/Libraries/Utilities/Platform.android.js +3 -3
- package/Libraries/Utilities/Platform.d.ts +1 -0
- package/Libraries/Utilities/Platform.ios.js +1 -1
- package/Libraries/Utilities/Platform.win32.js +3 -3
- package/Libraries/Utilities/PlatformTypes.js +1 -1
- package/Libraries/Utilities/ReactNativeTestTools.js +12 -0
- package/Libraries/Utilities/SceneTracker.js +1 -1
- package/Libraries/Utilities/codegenNativeCommands.js +1 -1
- package/Libraries/Utilities/codegenNativeComponent.js +1 -1
- package/Libraries/Utilities/createPerformanceLogger.js +32 -0
- package/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js +2 -0
- package/Libraries/Utilities/differ/pointsDiffer.js +1 -1
- package/Libraries/Utilities/useMergeRefs.js +1 -1
- package/Libraries/WebSocket/WebSocketInterceptor.js +2 -0
- package/Libraries/promiseRejectionTrackingOptions.js +17 -31
- package/Libraries/vendor/emitter/EventEmitter.js +1 -1
- package/flow/bom.js.flow +223 -1
- package/flow/prettier.js.flow +14 -0
- package/index.js +14 -2
- package/index.win32.js +16 -2
- package/jest/local-setup.js +2 -2
- package/jest/mock.js +1 -1
- package/jest/mockComponent.js +9 -9
- package/jest/mockNativeComponent.js +3 -2
- package/jest/mocks/Modal.js +1 -1
- package/jest/mocks/ScrollView.js +1 -1
- package/jest/mocks/ViewNativeComponent.js +1 -1
- package/jest/setup.js +23 -12
- package/overrides.json +23 -23
- package/package.json +28 -27
- package/saveAssetPlugin.js +2 -2
- package/src/private/animated/NativeAnimatedHelper.js +16 -5
- package/src/private/animated/NativeAnimatedHelper.win32.js +16 -5
- package/src/private/animated/createAnimatedPropsHook.js +11 -60
- package/src/private/animated/createAnimatedPropsMemoHook.js +8 -54
- package/src/private/components/virtualview/VirtualView.js +43 -12
- package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +93 -0
- package/src/private/components/virtualview/VirtualViewNativeComponent.js +6 -0
- package/src/private/devsupport/devmenu/elementinspector/Inspector.js +2 -2
- package/src/private/devsupport/devmenu/elementinspector/ReactDevToolsOverlay.js +2 -2
- package/src/private/featureflags/ReactNativeFeatureFlags.js +85 -52
- package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +23 -4
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +15 -6
- package/src/private/renderer/errorhandling/ErrorHandlers.js +3 -3
- package/src/private/setup/{setUpPerformanceObserver.js → setUpPerformanceModern.js} +43 -18
- package/src/private/specs_DEPRECATED/modules/NativeTiming.js +1 -0
- package/src/private/types/HostInstance.js +4 -1
- package/src/private/webapis/dom/nodes/ReactNativeDocument.js +22 -2
- package/src/private/webapis/dom/nodes/ReactNativeElement.js +1 -1
- package/src/private/webapis/dom/nodes/ReadOnlyElement.js +5 -3
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +16 -13
- package/src/private/webapis/dom/nodes/internals/NodeInternals.js +45 -22
- package/src/private/webapis/dom/nodes/internals/ReactNativeDocumentInstanceHandle.js +1 -1
- package/src/private/webapis/dom/nodes/specs/NativeDOM.js +26 -192
- package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +15 -12
- package/src/private/webapis/dom/oldstylecollections/NodeList.js +14 -11
- package/src/private/webapis/geometry/DOMRectList.js +2 -2
- package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +19 -74
- package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +0 -4
- package/src/private/webapis/mutationobserver/internals/MutationObserverManager.js +1 -1
- package/src/private/webapis/performance/EventTiming.js +40 -25
- package/src/private/webapis/performance/LongTasks.js +35 -2
- package/src/private/webapis/performance/Performance.js +347 -166
- package/src/private/webapis/performance/PerformanceEntry.js +40 -23
- package/src/private/webapis/performance/PerformanceObserver.js +37 -29
- package/src/private/webapis/performance/ReactNativeStartupTiming.js +3 -24
- package/src/private/webapis/performance/ResourceTiming.js +29 -18
- package/src/private/webapis/performance/UserTiming.js +92 -34
- package/src/private/webapis/performance/UserTimingExtensibility.js.flow +38 -0
- package/src/private/webapis/performance/internals/RawPerformanceEntry.js +3 -4
- package/src/private/webapis/performance/internals/Utilities.js +9 -0
- package/src/private/webapis/performance/specs/NativePerformance.js +23 -23
- package/src/private/webapis/structuredClone/structuredClone.js +10 -10
- package/src-win/Libraries/Components/Touchable/TouchableWin32.tsx +1 -1
- package/Libraries/Interaction/InteractionManagerStub.js +0 -184
- package/Libraries/Interaction/TaskQueue.js +0 -183
- package/Libraries/ReactNative/ReactNativeFeatureFlags.js +0 -31
|
@@ -14,9 +14,9 @@ import type {RootTag} from '../../../../../Libraries/ReactNative/RootTag';
|
|
|
14
14
|
import type {ViewConfig} from '../../../../../Libraries/Renderer/shims/ReactNativeTypes';
|
|
15
15
|
import type HTMLCollection from '../oldstylecollections/HTMLCollection';
|
|
16
16
|
import type {ReactNativeDocumentInstanceHandle} from './internals/ReactNativeDocumentInstanceHandle';
|
|
17
|
-
import type ReadOnlyElement from './ReadOnlyElement';
|
|
18
17
|
|
|
19
18
|
import {createHTMLCollection} from '../oldstylecollections/HTMLCollection';
|
|
19
|
+
import {getPublicInstanceFromInstanceHandle} from './internals/NodeInternals';
|
|
20
20
|
import {
|
|
21
21
|
createReactNativeDocumentElementInstanceHandle,
|
|
22
22
|
setNativeElementReferenceForReactNativeDocumentElementInstanceHandle,
|
|
@@ -24,10 +24,12 @@ import {
|
|
|
24
24
|
} from './internals/ReactNativeDocumentElementInstanceHandle';
|
|
25
25
|
import {createReactNativeDocumentInstanceHandle} from './internals/ReactNativeDocumentInstanceHandle';
|
|
26
26
|
import ReactNativeElement from './ReactNativeElement';
|
|
27
|
+
import ReadOnlyElement from './ReadOnlyElement';
|
|
27
28
|
import ReadOnlyNode from './ReadOnlyNode';
|
|
28
29
|
import NativeDOM from './specs/NativeDOM';
|
|
29
30
|
|
|
30
31
|
export default class ReactNativeDocument extends ReadOnlyNode {
|
|
32
|
+
_rootTag: RootTag;
|
|
31
33
|
_documentElement: ReactNativeElement;
|
|
32
34
|
|
|
33
35
|
constructor(
|
|
@@ -35,6 +37,7 @@ export default class ReactNativeDocument extends ReadOnlyNode {
|
|
|
35
37
|
instanceHandle: ReactNativeDocumentInstanceHandle,
|
|
36
38
|
) {
|
|
37
39
|
super(instanceHandle, null);
|
|
40
|
+
this._rootTag = rootTag;
|
|
38
41
|
this._documentElement = createDocumentElement(rootTag, this);
|
|
39
42
|
}
|
|
40
43
|
|
|
@@ -71,10 +74,27 @@ export default class ReactNativeDocument extends ReadOnlyNode {
|
|
|
71
74
|
return null;
|
|
72
75
|
}
|
|
73
76
|
|
|
74
|
-
// $FlowExpectedError[incompatible-
|
|
77
|
+
// $FlowExpectedError[incompatible-type] This is defined as returning string in Node, but it's actually null in Document.
|
|
75
78
|
get textContent(): null {
|
|
76
79
|
return null;
|
|
77
80
|
}
|
|
81
|
+
|
|
82
|
+
getElementById(id: string): ReadOnlyElement | null {
|
|
83
|
+
const elementByIdInstanceHandle = NativeDOM.getElementById(
|
|
84
|
+
this._rootTag,
|
|
85
|
+
id,
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
if (elementByIdInstanceHandle == null) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const elementById = getPublicInstanceFromInstanceHandle(
|
|
93
|
+
elementByIdInstanceHandle,
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
return elementById instanceof ReadOnlyElement ? elementById : null;
|
|
97
|
+
}
|
|
78
98
|
}
|
|
79
99
|
|
|
80
100
|
function createDocumentElement(
|
|
@@ -220,9 +220,11 @@ export default class ReadOnlyElement extends ReadOnlyNode {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
function getChildElements(node: ReadOnlyNode): $ReadOnlyArray<ReadOnlyElement> {
|
|
223
|
-
// $
|
|
224
|
-
return getChildNodes(
|
|
225
|
-
|
|
223
|
+
// $FlowFixMe[incompatible-type]
|
|
224
|
+
return getChildNodes(
|
|
225
|
+
node,
|
|
226
|
+
(childNode: ReadOnlyNode) =>
|
|
227
|
+
childNode.nodeType === ReadOnlyNode.ELEMENT_NODE,
|
|
226
228
|
);
|
|
227
229
|
}
|
|
228
230
|
|
|
@@ -118,7 +118,11 @@ export default class ReadOnlyNode {
|
|
|
118
118
|
get parentElement(): ReadOnlyElement | null {
|
|
119
119
|
const parentNode = this.parentNode;
|
|
120
120
|
|
|
121
|
-
if (
|
|
121
|
+
if (
|
|
122
|
+
parentNode != null &&
|
|
123
|
+
parentNode.nodeType === ReadOnlyNode.ELEMENT_NODE
|
|
124
|
+
) {
|
|
125
|
+
// $FlowExpectedError[incompatible-type] parentNode is an instance of ReadOnlyElement as per the `nodeType` check
|
|
122
126
|
return parentNode;
|
|
123
127
|
}
|
|
124
128
|
|
|
@@ -292,6 +296,7 @@ setPlatformObject(ReadOnlyNode);
|
|
|
292
296
|
|
|
293
297
|
export function getChildNodes(
|
|
294
298
|
node: ReadOnlyNode,
|
|
299
|
+
filter?: (node: ReadOnlyNode) => boolean,
|
|
295
300
|
): $ReadOnlyArray<ReadOnlyNode> {
|
|
296
301
|
const shadowNode = getNativeNodeReference(node);
|
|
297
302
|
|
|
@@ -300,9 +305,16 @@ export function getChildNodes(
|
|
|
300
305
|
}
|
|
301
306
|
|
|
302
307
|
const childNodeInstanceHandles = NativeDOM.getChildNodes(shadowNode);
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
308
|
+
const childNodes = [];
|
|
309
|
+
for (const childNodeInstanceHandle of childNodeInstanceHandles) {
|
|
310
|
+
const childNode = getPublicInstanceFromInstanceHandle(
|
|
311
|
+
childNodeInstanceHandle,
|
|
312
|
+
);
|
|
313
|
+
if (childNode != null && (filter == null || filter(childNode))) {
|
|
314
|
+
childNodes.push(childNode);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return childNodes;
|
|
306
318
|
}
|
|
307
319
|
|
|
308
320
|
function getNodeSiblingsAndPosition(
|
|
@@ -323,12 +335,3 @@ function getNodeSiblingsAndPosition(
|
|
|
323
335
|
|
|
324
336
|
return [siblings, position];
|
|
325
337
|
}
|
|
326
|
-
|
|
327
|
-
let ReadOnlyElementClass;
|
|
328
|
-
function getReadOnlyElementClass(): Class<ReadOnlyElement> {
|
|
329
|
-
if (ReadOnlyElementClass == null) {
|
|
330
|
-
// We initialize this lazily to avoid a require cycle.
|
|
331
|
-
ReadOnlyElementClass = require('./ReadOnlyElement').default;
|
|
332
|
-
}
|
|
333
|
-
return ReadOnlyElementClass;
|
|
334
|
-
}
|
|
@@ -37,14 +37,30 @@ export type InstanceHandle =
|
|
|
37
37
|
| ReactNativeDocumentElementInstanceHandle // root element managed by React Native
|
|
38
38
|
| ReactNativeDocumentInstanceHandle; // document node managed by React Native
|
|
39
39
|
|
|
40
|
-
let
|
|
41
|
-
function
|
|
42
|
-
|
|
40
|
+
let cachedGetNodeFromInternalInstanceHandle;
|
|
41
|
+
function getNodeFromInternalInstanceHandle(
|
|
42
|
+
instanceHandle: InternalInstanceHandle,
|
|
43
|
+
) {
|
|
44
|
+
if (cachedGetNodeFromInternalInstanceHandle == null) {
|
|
43
45
|
// Lazy import Fabric here to avoid DOM Node APIs classes from having side-effects.
|
|
44
46
|
// With a static import we can't use these classes for Paper-only variants.
|
|
45
|
-
|
|
47
|
+
cachedGetNodeFromInternalInstanceHandle =
|
|
48
|
+
require('../../../../../../Libraries/ReactNative/RendererProxy').getNodeFromInternalInstanceHandle;
|
|
46
49
|
}
|
|
47
|
-
return
|
|
50
|
+
return cachedGetNodeFromInternalInstanceHandle(instanceHandle);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let cachedGetPublicInstanceFromInternalInstanceHandle;
|
|
54
|
+
function getPublicInstanceFromInternalInstanceHandle(
|
|
55
|
+
instanceHandle: InternalInstanceHandle,
|
|
56
|
+
) {
|
|
57
|
+
if (cachedGetPublicInstanceFromInternalInstanceHandle == null) {
|
|
58
|
+
// Lazy import Fabric here to avoid DOM Node APIs classes from having side-effects.
|
|
59
|
+
// With a static import we can't use these classes for Paper-only variants.
|
|
60
|
+
cachedGetPublicInstanceFromInternalInstanceHandle =
|
|
61
|
+
require('../../../../../../Libraries/ReactNative/RendererProxy').getPublicInstanceFromInternalInstanceHandle;
|
|
62
|
+
}
|
|
63
|
+
return cachedGetPublicInstanceFromInternalInstanceHandle(instanceHandle);
|
|
48
64
|
}
|
|
49
65
|
|
|
50
66
|
const INSTANCE_HANDLE_KEY = Symbol('internalInstanceHandle');
|
|
@@ -81,6 +97,15 @@ export function setOwnerDocument(
|
|
|
81
97
|
export function getPublicInstanceFromInstanceHandle(
|
|
82
98
|
instanceHandle: InstanceHandle,
|
|
83
99
|
): ?ReadOnlyNode {
|
|
100
|
+
const mixedPublicInstance =
|
|
101
|
+
// $FlowExpectedError[incompatible-type]
|
|
102
|
+
getPublicInstanceFromInternalInstanceHandle(instanceHandle);
|
|
103
|
+
|
|
104
|
+
if (mixedPublicInstance != null) {
|
|
105
|
+
// $FlowExpectedError[incompatible-type] React defines public instances as "mixed" because it can't access the definition from React Native.
|
|
106
|
+
return mixedPublicInstance;
|
|
107
|
+
}
|
|
108
|
+
|
|
84
109
|
if (isReactNativeDocumentInstanceHandle(instanceHandle)) {
|
|
85
110
|
return getPublicInstanceFromReactNativeDocumentInstanceHandle(
|
|
86
111
|
instanceHandle,
|
|
@@ -92,14 +117,6 @@ export function getPublicInstanceFromInstanceHandle(
|
|
|
92
117
|
instanceHandle,
|
|
93
118
|
);
|
|
94
119
|
}
|
|
95
|
-
|
|
96
|
-
const mixedPublicInstance =
|
|
97
|
-
getRendererProxy().getPublicInstanceFromInternalInstanceHandle(
|
|
98
|
-
instanceHandle,
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
// $FlowExpectedError[incompatible-return] React defines public instances as "mixed" because it can't access the definition from React Native.
|
|
102
|
-
return mixedPublicInstance;
|
|
103
120
|
}
|
|
104
121
|
|
|
105
122
|
export function getNativeNodeReference(
|
|
@@ -107,6 +124,15 @@ export function getNativeNodeReference(
|
|
|
107
124
|
): ?NativeNodeReference {
|
|
108
125
|
const instanceHandle = getInstanceHandle(node);
|
|
109
126
|
|
|
127
|
+
// Try React nodes first
|
|
128
|
+
const nativeReference =
|
|
129
|
+
// $FlowExpectedError[incompatible-type]
|
|
130
|
+
getNodeFromInternalInstanceHandle(instanceHandle);
|
|
131
|
+
if (nativeReference != null) {
|
|
132
|
+
// $FlowExpectedError[incompatible-type]
|
|
133
|
+
return nativeReference;
|
|
134
|
+
}
|
|
135
|
+
|
|
110
136
|
if (isReactNativeDocumentInstanceHandle(instanceHandle)) {
|
|
111
137
|
return getNativeNodeReferenceFromReactNativeDocumentInstanceHandle(
|
|
112
138
|
instanceHandle,
|
|
@@ -118,15 +144,12 @@ export function getNativeNodeReference(
|
|
|
118
144
|
instanceHandle,
|
|
119
145
|
);
|
|
120
146
|
}
|
|
121
|
-
|
|
122
|
-
// $FlowExpectedError[incompatible-return]
|
|
123
|
-
return getRendererProxy().getNodeFromInternalInstanceHandle(instanceHandle);
|
|
124
147
|
}
|
|
125
148
|
|
|
126
149
|
export function getNativeElementReference(
|
|
127
150
|
node: ReadOnlyElement,
|
|
128
151
|
): ?NativeElementReference {
|
|
129
|
-
// $FlowExpectedError[incompatible-
|
|
152
|
+
// $FlowExpectedError[incompatible-type] We know ReadOnlyElement instances provide InternalInstanceHandle
|
|
130
153
|
const instanceHandle = getInstanceHandle(node) as InternalInstanceHandle;
|
|
131
154
|
|
|
132
155
|
if (isReactNativeDocumentElementInstanceHandle(instanceHandle)) {
|
|
@@ -135,16 +158,16 @@ export function getNativeElementReference(
|
|
|
135
158
|
);
|
|
136
159
|
}
|
|
137
160
|
|
|
138
|
-
// $FlowExpectedError[incompatible-
|
|
139
|
-
return
|
|
161
|
+
// $FlowExpectedError[incompatible-type]
|
|
162
|
+
return getNodeFromInternalInstanceHandle(instanceHandle);
|
|
140
163
|
}
|
|
141
164
|
|
|
142
165
|
export function getNativeTextReference(
|
|
143
166
|
node: ReadOnlyCharacterData,
|
|
144
167
|
): ?NativeTextReference {
|
|
145
|
-
// $FlowExpectedError[incompatible-
|
|
168
|
+
// $FlowExpectedError[incompatible-type] We know ReadOnlyText instances provide InternalInstanceHandle
|
|
146
169
|
const instanceHandle = getInstanceHandle(node) as InternalInstanceHandle;
|
|
147
170
|
|
|
148
|
-
// $FlowExpectedError[incompatible-
|
|
149
|
-
return
|
|
171
|
+
// $FlowExpectedError[incompatible-type]
|
|
172
|
+
return getNodeFromInternalInstanceHandle(instanceHandle);
|
|
150
173
|
}
|
|
@@ -31,7 +31,7 @@ export function getNativeNodeReferenceFromReactNativeDocumentInstanceHandle(
|
|
|
31
31
|
export function getPublicInstanceFromReactNativeDocumentInstanceHandle(
|
|
32
32
|
instanceHandle: ReactNativeDocumentInstanceHandle,
|
|
33
33
|
): ?ReactNativeDocument {
|
|
34
|
-
// $FlowExpectedError[incompatible-
|
|
34
|
+
// $FlowExpectedError[incompatible-type] React defines public instances as "mixed" because it can't access the definition from React Native.
|
|
35
35
|
return RendererProxy.getPublicInstanceFromRootTag(Number(instanceHandle));
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -13,9 +13,7 @@ import type {Node as ShadowNode} from '../../../../../../Libraries/Renderer/shim
|
|
|
13
13
|
import type {TurboModule} from '../../../../../../Libraries/TurboModule/RCTExport';
|
|
14
14
|
import type {InstanceHandle} from '../internals/NodeInternals';
|
|
15
15
|
|
|
16
|
-
import {getFabricUIManager} from '../../../../../../Libraries/ReactNative/FabricUIManager';
|
|
17
16
|
import * as TurboModuleRegistry from '../../../../../../Libraries/TurboModule/TurboModuleRegistry';
|
|
18
|
-
import nullthrows from 'nullthrows';
|
|
19
17
|
|
|
20
18
|
export opaque type NativeElementReference = ShadowNode;
|
|
21
19
|
export opaque type NativeTextReference = ShadowNode;
|
|
@@ -62,6 +60,11 @@ export interface Spec extends TurboModule {
|
|
|
62
60
|
nativeNodeReference: mixed /* NativeNodeReference */,
|
|
63
61
|
) => $ReadOnlyArray<mixed> /* $ReadOnlyArray<InstanceHandle> */;
|
|
64
62
|
|
|
63
|
+
+getElementById?: (
|
|
64
|
+
nativeNodeReference: mixed /* NativeNodeReference */,
|
|
65
|
+
id: string,
|
|
66
|
+
) => mixed /* ?InstanceHandle */;
|
|
67
|
+
|
|
65
68
|
+getParentNode: (
|
|
66
69
|
nativeNodeReference: mixed /* NativeNodeReference */,
|
|
67
70
|
) => mixed /* ?InstanceHandle */;
|
|
@@ -160,18 +163,12 @@ export interface Spec extends TurboModule {
|
|
|
160
163
|
* Legacy direct manipulation APIs (for `ReactNativeElement`).
|
|
161
164
|
*/
|
|
162
165
|
|
|
163
|
-
+setNativeProps
|
|
166
|
+
+setNativeProps: (
|
|
164
167
|
nativeElementReference: mixed,
|
|
165
168
|
updatePayload: mixed,
|
|
166
169
|
) => void;
|
|
167
170
|
}
|
|
168
171
|
|
|
169
|
-
const RawNativeDOM = (TurboModuleRegistry.get<Spec>('NativeDOMCxx'): ?Spec);
|
|
170
|
-
|
|
171
|
-
export function getRawNativeDOMForTests(): ?Spec {
|
|
172
|
-
return RawNativeDOM;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
172
|
// This is the actual interface of this module, but the native module codegen
|
|
176
173
|
// isn't expressive enough yet.
|
|
177
174
|
export interface RefinedSpec {
|
|
@@ -204,6 +201,15 @@ export interface RefinedSpec {
|
|
|
204
201
|
nativeNodeReference: NativeNodeReference,
|
|
205
202
|
) => $ReadOnlyArray<InstanceHandle>;
|
|
206
203
|
|
|
204
|
+
/**
|
|
205
|
+
* This is a React Native implementation of `Document.prototype.getElementById`
|
|
206
|
+
* (see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById).
|
|
207
|
+
*
|
|
208
|
+
* If the document is active and contains an element with the given ID, it
|
|
209
|
+
* returns the instance handle of that element. Otherwise, it returns `null`.
|
|
210
|
+
*/
|
|
211
|
+
+getElementById: (rootTag: RootTag, id: string) => ?InstanceHandle;
|
|
212
|
+
|
|
207
213
|
/**
|
|
208
214
|
* This is a React Native implementation of `Node.prototype.parentNode`
|
|
209
215
|
* (see https://developer.mozilla.org/en-US/docs/Web/API/Node/parentNode).
|
|
@@ -432,186 +438,14 @@ export interface RefinedSpec {
|
|
|
432
438
|
) => void;
|
|
433
439
|
}
|
|
434
440
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
getChildNodes(nativeNodeReference) {
|
|
448
|
-
// $FlowExpectedError[incompatible-cast]
|
|
449
|
-
return (nullthrows(RawNativeDOM).getChildNodes(
|
|
450
|
-
nativeNodeReference,
|
|
451
|
-
): $ReadOnlyArray<InstanceHandle>);
|
|
452
|
-
},
|
|
453
|
-
|
|
454
|
-
getParentNode(nativeNodeReference) {
|
|
455
|
-
// $FlowExpectedError[incompatible-cast]
|
|
456
|
-
return (nullthrows(RawNativeDOM).getParentNode(
|
|
457
|
-
nativeNodeReference,
|
|
458
|
-
): ?InstanceHandle);
|
|
459
|
-
},
|
|
460
|
-
|
|
461
|
-
isConnected(nativeNodeReference) {
|
|
462
|
-
return nullthrows(RawNativeDOM).isConnected(nativeNodeReference);
|
|
463
|
-
},
|
|
464
|
-
|
|
465
|
-
/*
|
|
466
|
-
* Methods from the `Element` interface (for `ReactNativeElement`).
|
|
467
|
-
*/
|
|
468
|
-
|
|
469
|
-
getBorderWidth(nativeNodeReference) {
|
|
470
|
-
// $FlowExpectedError[incompatible-cast]
|
|
471
|
-
return (nullthrows(RawNativeDOM).getBorderWidth(
|
|
472
|
-
nativeNodeReference,
|
|
473
|
-
): $ReadOnly<
|
|
474
|
-
[
|
|
475
|
-
/* topWidth: */ number,
|
|
476
|
-
/* rightWidth: */ number,
|
|
477
|
-
/* bottomWidth: */ number,
|
|
478
|
-
/* leftWidth: */ number,
|
|
479
|
-
],
|
|
480
|
-
>);
|
|
481
|
-
},
|
|
482
|
-
|
|
483
|
-
getBoundingClientRect(nativeNodeReference, includeTransform: boolean) {
|
|
484
|
-
// $FlowExpectedError[incompatible-cast]
|
|
485
|
-
return (nullthrows(RawNativeDOM).getBoundingClientRect(
|
|
486
|
-
nativeNodeReference,
|
|
487
|
-
includeTransform,
|
|
488
|
-
): $ReadOnly<
|
|
489
|
-
[
|
|
490
|
-
/* x: */ number,
|
|
491
|
-
/* y: */ number,
|
|
492
|
-
/* width: */ number,
|
|
493
|
-
/* height: */ number,
|
|
494
|
-
],
|
|
495
|
-
>);
|
|
496
|
-
},
|
|
497
|
-
|
|
498
|
-
getInnerSize(nativeNodeReference) {
|
|
499
|
-
// $FlowExpectedError[incompatible-cast]
|
|
500
|
-
return (nullthrows(RawNativeDOM).getInnerSize(
|
|
501
|
-
nativeNodeReference,
|
|
502
|
-
): $ReadOnly<[/* width: */ number, /* height: */ number]>);
|
|
503
|
-
},
|
|
504
|
-
|
|
505
|
-
getScrollPosition(nativeNodeReference) {
|
|
506
|
-
// $FlowExpectedError[incompatible-cast]
|
|
507
|
-
return (nullthrows(RawNativeDOM).getScrollPosition(
|
|
508
|
-
nativeNodeReference,
|
|
509
|
-
): $ReadOnly<[/* scrollLeft: */ number, /* scrollTop: */ number]>);
|
|
510
|
-
},
|
|
511
|
-
|
|
512
|
-
getScrollSize(nativeNodeReference) {
|
|
513
|
-
// $FlowExpectedError[incompatible-cast]
|
|
514
|
-
return (nullthrows(RawNativeDOM).getScrollSize(
|
|
515
|
-
nativeNodeReference,
|
|
516
|
-
): $ReadOnly<[/* scrollWidth: */ number, /* scrollHeight: */ number]>);
|
|
517
|
-
},
|
|
518
|
-
|
|
519
|
-
getTagName(nativeNodeReference) {
|
|
520
|
-
return nullthrows(RawNativeDOM).getTagName(nativeNodeReference);
|
|
521
|
-
},
|
|
522
|
-
|
|
523
|
-
getTextContent(nativeNodeReference) {
|
|
524
|
-
return nullthrows(RawNativeDOM).getTextContent(nativeNodeReference);
|
|
525
|
-
},
|
|
526
|
-
|
|
527
|
-
hasPointerCapture(nativeNodeReference, pointerId) {
|
|
528
|
-
return nullthrows(RawNativeDOM).hasPointerCapture(
|
|
529
|
-
nativeNodeReference,
|
|
530
|
-
pointerId,
|
|
531
|
-
);
|
|
532
|
-
},
|
|
533
|
-
|
|
534
|
-
releasePointerCapture(nativeNodeReference, pointerId) {
|
|
535
|
-
return nullthrows(RawNativeDOM).releasePointerCapture(
|
|
536
|
-
nativeNodeReference,
|
|
537
|
-
pointerId,
|
|
538
|
-
);
|
|
539
|
-
},
|
|
540
|
-
|
|
541
|
-
setPointerCapture(nativeNodeReference, pointerId) {
|
|
542
|
-
return nullthrows(RawNativeDOM).setPointerCapture(
|
|
543
|
-
nativeNodeReference,
|
|
544
|
-
pointerId,
|
|
545
|
-
);
|
|
546
|
-
},
|
|
547
|
-
|
|
548
|
-
/*
|
|
549
|
-
* Methods from the `HTMLElement` interface (for `ReactNativeElement`).
|
|
550
|
-
*/
|
|
551
|
-
|
|
552
|
-
getOffset(nativeNodeReference) {
|
|
553
|
-
// $FlowExpectedError[incompatible-cast]
|
|
554
|
-
return (nullthrows(RawNativeDOM).getOffset(nativeNodeReference): $ReadOnly<
|
|
555
|
-
[
|
|
556
|
-
/* offsetParent: */ ?InstanceHandle,
|
|
557
|
-
/* top: */ number,
|
|
558
|
-
/* left: */ number,
|
|
559
|
-
],
|
|
560
|
-
>);
|
|
561
|
-
},
|
|
562
|
-
|
|
563
|
-
/*
|
|
564
|
-
* Special methods to handle the root node.
|
|
565
|
-
*/
|
|
566
|
-
|
|
567
|
-
linkRootNode(rootTag, instanceHandle) {
|
|
568
|
-
// $FlowExpectedError[incompatible-cast]
|
|
569
|
-
return (nullthrows(RawNativeDOM?.linkRootNode)(
|
|
570
|
-
// $FlowExpectedError[incompatible-call]
|
|
571
|
-
rootTag,
|
|
572
|
-
instanceHandle,
|
|
573
|
-
): ?NativeElementReference);
|
|
574
|
-
},
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* Legacy layout APIs
|
|
578
|
-
*/
|
|
579
|
-
|
|
580
|
-
measure(nativeNodeReference, callback) {
|
|
581
|
-
return nullthrows(RawNativeDOM).measure(nativeNodeReference, callback);
|
|
582
|
-
},
|
|
583
|
-
|
|
584
|
-
measureInWindow(nativeNodeReference, callback) {
|
|
585
|
-
return nullthrows(RawNativeDOM).measureInWindow(
|
|
586
|
-
nativeNodeReference,
|
|
587
|
-
callback,
|
|
588
|
-
);
|
|
589
|
-
},
|
|
590
|
-
|
|
591
|
-
measureLayout(nativeNodeReference, relativeNode, onFail, onSuccess) {
|
|
592
|
-
return nullthrows(RawNativeDOM).measureLayout(
|
|
593
|
-
nativeNodeReference,
|
|
594
|
-
relativeNode,
|
|
595
|
-
onFail,
|
|
596
|
-
onSuccess,
|
|
597
|
-
);
|
|
598
|
-
},
|
|
599
|
-
|
|
600
|
-
/**
|
|
601
|
-
* Legacy direct manipulation APIs
|
|
602
|
-
*/
|
|
603
|
-
setNativeProps(nativeNodeReference, updatePayload) {
|
|
604
|
-
// TODO: remove when RawNativeDOM.setNativeProps is NOT nullable.
|
|
605
|
-
if (RawNativeDOM?.setNativeProps == null) {
|
|
606
|
-
nullthrows(getFabricUIManager()).setNativeProps(
|
|
607
|
-
nativeNodeReference,
|
|
608
|
-
updatePayload,
|
|
609
|
-
);
|
|
610
|
-
return;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
return RawNativeDOM.setNativeProps(nativeNodeReference, updatePayload);
|
|
614
|
-
},
|
|
615
|
-
};
|
|
616
|
-
|
|
617
|
-
export default NativeDOM;
|
|
441
|
+
// We used to implement all methods in RefineSpec, manually refining the types
|
|
442
|
+
// for all methods. However, this is slower as every call to the native module
|
|
443
|
+
// requires an additional call only to handle types. Instead, we do an unsafe
|
|
444
|
+
// casting here. Keep in mind that:
|
|
445
|
+
// 1. We use `get` and not `getEnforcing` because we don't want to fail when
|
|
446
|
+
// the module is evaluated, only when used. This is necessary because we
|
|
447
|
+
// don't use inline requires within the `react-native` package and some code
|
|
448
|
+
// might end up loading this but not using it.
|
|
449
|
+
// 2. We lose automatic backwards compatibility checks because of this.
|
|
450
|
+
// $FlowExpectedError[incompatible-type]
|
|
451
|
+
export default (TurboModuleRegistry.get<Spec>('NativeDOMCxx'): RefinedSpec);
|
|
@@ -18,9 +18,16 @@ import {setPlatformObject} from '../../webidl/PlatformObjects';
|
|
|
18
18
|
// IMPORTANT: The type definition for this module is defined in `HTMLCollection.js.flow`
|
|
19
19
|
// because Flow only supports indexers in classes in declaration files.
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const REUSABLE_PROPERTY_DESCRIPTOR: {...PropertyDescriptor<mixed>, ...} = {
|
|
22
|
+
value: {},
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: false,
|
|
25
|
+
writable: false,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// $FlowFixMe[incompatible-type] Flow doesn't understand [Symbol.iterator]() {} and thinks this class doesn't implement the Iterable<T> interface.
|
|
22
29
|
export default class HTMLCollection<T> implements Iterable<T>, ArrayLike<T> {
|
|
23
|
-
|
|
30
|
+
_length: number;
|
|
24
31
|
|
|
25
32
|
/**
|
|
26
33
|
* Use `createHTMLCollection` to create instances of this class.
|
|
@@ -30,23 +37,19 @@ export default class HTMLCollection<T> implements Iterable<T>, ArrayLike<T> {
|
|
|
30
37
|
*/
|
|
31
38
|
constructor(elements: $ReadOnlyArray<T>) {
|
|
32
39
|
for (let i = 0; i < elements.length; i++) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
enumerable: true,
|
|
36
|
-
configurable: false,
|
|
37
|
-
writable: false,
|
|
38
|
-
});
|
|
40
|
+
REUSABLE_PROPERTY_DESCRIPTOR.value = elements[i];
|
|
41
|
+
Object.defineProperty(this, i, REUSABLE_PROPERTY_DESCRIPTOR);
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
this
|
|
44
|
+
this._length = elements.length;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
get length(): number {
|
|
45
|
-
return this
|
|
48
|
+
return this._length;
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
item(index: number): T | null {
|
|
49
|
-
if (index < 0 || index >= this
|
|
52
|
+
if (index < 0 || index >= this._length) {
|
|
50
53
|
return null;
|
|
51
54
|
}
|
|
52
55
|
|
|
@@ -64,7 +67,7 @@ export default class HTMLCollection<T> implements Iterable<T>, ArrayLike<T> {
|
|
|
64
67
|
return null;
|
|
65
68
|
}
|
|
66
69
|
|
|
67
|
-
// $
|
|
70
|
+
// $FlowFixMe[unsupported-syntax] Flow does not support computed properties in classes.
|
|
68
71
|
[Symbol.iterator](): Iterator<T> {
|
|
69
72
|
return createValueIterator(this);
|
|
70
73
|
}
|
|
@@ -22,9 +22,14 @@ import {setPlatformObject} from '../../webidl/PlatformObjects';
|
|
|
22
22
|
// IMPORTANT: The Flow type definition for this module is defined in `NodeList.js.flow`
|
|
23
23
|
// because Flow only supports indexers in classes in declaration files.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const REUSABLE_PROPERTY_DESCRIPTOR: {...PropertyDescriptor<mixed>, ...} = {
|
|
26
|
+
value: {},
|
|
27
|
+
writable: false,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// $FlowFixMe[incompatible-type] Flow doesn't understand [Symbol.iterator]() {} and thinks this class doesn't implement the Iterable<T> interface.
|
|
26
31
|
export default class NodeList<T> implements Iterable<T>, ArrayLike<T> {
|
|
27
|
-
|
|
32
|
+
_length: number;
|
|
28
33
|
|
|
29
34
|
/**
|
|
30
35
|
* Use `createNodeList` to create instances of this class.
|
|
@@ -34,20 +39,18 @@ export default class NodeList<T> implements Iterable<T>, ArrayLike<T> {
|
|
|
34
39
|
*/
|
|
35
40
|
constructor(elements: $ReadOnlyArray<T>) {
|
|
36
41
|
for (let i = 0; i < elements.length; i++) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
writable: false,
|
|
40
|
-
});
|
|
42
|
+
REUSABLE_PROPERTY_DESCRIPTOR.value = elements[i];
|
|
43
|
+
Object.defineProperty(this, i, REUSABLE_PROPERTY_DESCRIPTOR);
|
|
41
44
|
}
|
|
42
|
-
this
|
|
45
|
+
this._length = elements.length;
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
get length(): number {
|
|
46
|
-
return this
|
|
49
|
+
return this._length;
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
item(index: number): T | null {
|
|
50
|
-
if (index < 0 || index >= this
|
|
53
|
+
if (index < 0 || index >= this._length) {
|
|
51
54
|
return null;
|
|
52
55
|
}
|
|
53
56
|
|
|
@@ -71,7 +74,7 @@ export default class NodeList<T> implements Iterable<T>, ArrayLike<T> {
|
|
|
71
74
|
// eslint-disable-next-line consistent-this
|
|
72
75
|
const arrayLike: ArrayLike<T> = this;
|
|
73
76
|
|
|
74
|
-
for (let index = 0; index < this
|
|
77
|
+
for (let index = 0; index < this._length; index++) {
|
|
75
78
|
if (thisArg == null) {
|
|
76
79
|
callbackFn(arrayLike[index], index, this);
|
|
77
80
|
} else {
|
|
@@ -88,7 +91,7 @@ export default class NodeList<T> implements Iterable<T>, ArrayLike<T> {
|
|
|
88
91
|
return createValueIterator(this);
|
|
89
92
|
}
|
|
90
93
|
|
|
91
|
-
// $
|
|
94
|
+
// $FlowFixMe[unsupported-syntax] Flow does not support computed properties in classes.
|
|
92
95
|
[Symbol.iterator](): Iterator<T> {
|
|
93
96
|
return createValueIterator(this);
|
|
94
97
|
}
|
|
@@ -19,7 +19,7 @@ import {setPlatformObject} from '../webidl/PlatformObjects';
|
|
|
19
19
|
// IMPORTANT: The Flow type definition for this module is defined in `DOMRectList.js.flow`
|
|
20
20
|
// because Flow only supports indexers in classes in declaration files.
|
|
21
21
|
|
|
22
|
-
// $
|
|
22
|
+
// $FlowFixMe[incompatible-type] Flow doesn't understand [Symbol.iterator]() {} and thinks this class doesn't implement the Iterable interface.
|
|
23
23
|
export default class DOMRectList implements Iterable<DOMRectReadOnly> {
|
|
24
24
|
#length: number;
|
|
25
25
|
|
|
@@ -58,7 +58,7 @@ export default class DOMRectList implements Iterable<DOMRectReadOnly> {
|
|
|
58
58
|
return arrayLike[index];
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
// $
|
|
61
|
+
// $FlowFixMe[unsupported-syntax] Flow does not support computed properties in classes.
|
|
62
62
|
[Symbol.iterator](): Iterator<DOMRectReadOnly> {
|
|
63
63
|
return createValueIterator(this);
|
|
64
64
|
}
|