Skip to content

Commit 08ce0f9

Browse files
rubennortefacebook-github-bot
authored andcommitted
Move DOM APIs to native module (facebook#43512)
Summary: Changelog: [internal] This moves all the new methods that were added to implement the DOM traversal and layout APIs (as per this RFC: react-native-community/discussions-and-proposals#607) to a separate C++ native module to avoid bloating the UIManager interface, initialize lazily, provide automatic caching of methods, simplify the API for implementors, etc. Reviewed By: sammy-SC Differential Revision: D54903376
1 parent 1fe8267 commit 08ce0f9

File tree

15 files changed

+1261
-1053
lines changed

15 files changed

+1261
-1053
lines changed

packages/react-native/Libraries/ReactNative/FabricUIManager.js

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,7 @@ export interface Spec {
7070
locationY: number,
7171
callback: (instanceHandle: ?InternalInstanceHandle) => void,
7272
) => void;
73-
74-
/**
75-
* Support methods for the DOM-compatible APIs.
76-
*/
77-
+getParentNode: (node: Node) => ?InternalInstanceHandle;
78-
+getChildNodes: (node: Node) => $ReadOnlyArray<InternalInstanceHandle>;
79-
+isConnected: (node: Node) => boolean;
8073
+compareDocumentPosition: (node: Node, otherNode: Node) => number;
81-
+getTextContent: (node: Node) => string;
8274
+getBoundingClientRect: (
8375
node: Node,
8476
includeTransform: boolean,
@@ -88,36 +80,6 @@ export interface Spec {
8880
/* width: */ number,
8981
/* height: */ number,
9082
];
91-
+getOffset: (
92-
node: Node,
93-
) => ?[
94-
/* offsetParent: */ InternalInstanceHandle,
95-
/* offsetTop: */ number,
96-
/* offsetLeft: */ number,
97-
];
98-
+getScrollPosition: (
99-
node: Node,
100-
) => ?[/* scrollLeft: */ number, /* scrollTop: */ number];
101-
+getScrollSize: (
102-
node: Node,
103-
) => ?[/* scrollWidth: */ number, /* scrollHeight: */ number];
104-
+getInnerSize: (node: Node) => ?[/* width: */ number, /* height: */ number];
105-
+getBorderSize: (
106-
node: Node,
107-
) => ?[
108-
/* topWidth: */ number,
109-
/* rightWidth: */ number,
110-
/* bottomWidth: */ number,
111-
/* leftWidth: */ number,
112-
];
113-
+getTagName: (node: Node) => string;
114-
115-
/**
116-
* Support methods for the Pointer Capture APIs.
117-
*/
118-
+hasPointerCapture: (node: Node, pointerId: number) => boolean;
119-
+setPointerCapture: (node: Node, pointerId: number) => void;
120-
+releasePointerCapture: (node: Node, pointerId: number) => void;
12183
}
12284

12385
let nativeFabricUIManagerProxy: ?Spec;
@@ -143,21 +105,8 @@ const CACHED_PROPERTIES = [
143105
'findShadowNodeByTag_DEPRECATED',
144106
'setNativeProps',
145107
'dispatchCommand',
146-
'getParentNode',
147-
'getChildNodes',
148-
'isConnected',
149108
'compareDocumentPosition',
150-
'getTextContent',
151109
'getBoundingClientRect',
152-
'getOffset',
153-
'getScrollPosition',
154-
'getScrollSize',
155-
'getInnerSize',
156-
'getBorderSize',
157-
'getTagName',
158-
'hasPointerCapture',
159-
'setPointerCapture',
160-
'releasePointerCapture',
161110
];
162111

163112
// This is exposed as a getter because apps using the legacy renderer AND

packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/__tests__/ReactFabricPublicInstance-test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ jest.mock('../../FabricUIManager', () =>
3232
require('../../__mocks__/FabricUIManager'),
3333
);
3434

35+
jest.mock('../../../../src/private/webapis/dom/nodes/specs/NativeDOM', () =>
36+
require('../../../../src/private/webapis/dom/nodes/specs/__mocks__/NativeDOMMock'),
37+
);
38+
3539
/**
3640
* Given a mocked function, get a correctly typed mock function that preserves
3741
* the original function's type.

0 commit comments

Comments
 (0)