Skip to content

Commit cd65a32

Browse files
rubennortefacebook-github-bot
authored andcommitted
Add skeletons for ReadOnlyNode, ReadOnlyElement and ReactNativeElement
Summary: This just creates the class structure for `ReadOnlyNode`, `ReadOnlyElement` and `ReactNativeElement`, with all methods throwing as unimplemented. These classes will be gated behind a feature flag, so merging incomplete work is ok. This doesn't add the future setters that will log warnings / throw errors when used. See: react-native-community/discussions-and-proposals#607 Changelog: [internal] Reviewed By: rickhanlonii, yungsters Differential Revision: D44060539 fbshipit-source-id: e489532fd365d9aa2bb8308847a35eb715d675e7
1 parent a8b5ff8 commit cd65a32

File tree

3 files changed

+331
-0
lines changed

3 files changed

+331
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
* @flow strict
9+
*/
10+
11+
// flowlint unsafe-getters-setters:off
12+
13+
import type {
14+
HostComponent,
15+
MeasureInWindowOnSuccessCallback,
16+
MeasureLayoutOnSuccessCallback,
17+
MeasureOnSuccessCallback,
18+
} from '../../Renderer/shims/ReactNativeTypes';
19+
import type {ElementRef} from 'react';
20+
21+
import ReadOnlyElement from './ReadOnlyElement';
22+
23+
export default class ReactNativeElement extends ReadOnlyElement {
24+
get offsetHeight(): number {
25+
throw new TypeError('Unimplemented');
26+
}
27+
28+
get offsetLeft(): number {
29+
throw new TypeError('Unimplemented');
30+
}
31+
32+
get offsetParent(): ReadOnlyElement | null {
33+
throw new TypeError('Unimplemented');
34+
}
35+
36+
get offsetTop(): number {
37+
throw new TypeError('Unimplemented');
38+
}
39+
40+
get offsetWidth(): number {
41+
throw new TypeError('Unimplemented');
42+
}
43+
44+
/**
45+
* React Native compatibility methods
46+
*/
47+
48+
blur(): void {
49+
throw new TypeError('Unimplemented');
50+
}
51+
52+
focus(): void {
53+
throw new TypeError('Unimplemented');
54+
}
55+
56+
measure(callback: MeasureOnSuccessCallback): void {
57+
throw new TypeError('Unimplemented');
58+
}
59+
60+
measureInWindow(callback: MeasureInWindowOnSuccessCallback): void {
61+
throw new TypeError('Unimplemented');
62+
}
63+
64+
measureLayout(
65+
relativeToNativeNode: number | ElementRef<HostComponent<mixed>>,
66+
onSuccess: MeasureLayoutOnSuccessCallback,
67+
onFail?: () => void /* currently unused */,
68+
): void {
69+
throw new TypeError('Unimplemented');
70+
}
71+
72+
setNativeProps(nativeProps: {...}): void {
73+
throw new TypeError('Unimplemented');
74+
}
75+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
* @flow strict
9+
*/
10+
11+
// flowlint unsafe-getters-setters:off
12+
13+
import type HTMLCollection from '../OldStyleCollections/HTMLCollection';
14+
15+
import ReadOnlyNode from './ReadOnlyNode';
16+
17+
export default class ReadOnlyElement extends ReadOnlyNode {
18+
get childElementCount(): number {
19+
throw new TypeError('Unimplemented');
20+
}
21+
22+
get children(): HTMLCollection<ReadOnlyElement> {
23+
throw new TypeError('Unimplemented');
24+
}
25+
26+
get clientHeight(): number {
27+
throw new TypeError('Unimplemented');
28+
}
29+
30+
get clientLeft(): number {
31+
throw new TypeError('Unimplemented');
32+
}
33+
34+
get clientTop(): number {
35+
throw new TypeError('Unimplemented');
36+
}
37+
38+
get clientWidth(): number {
39+
throw new TypeError('Unimplemented');
40+
}
41+
42+
get firstElementChild(): ReadOnlyElement | null {
43+
throw new TypeError('Unimplemented');
44+
}
45+
46+
get id(): string {
47+
throw new TypeError('Unimplemented');
48+
}
49+
50+
get lastElementChild(): ReadOnlyElement | null {
51+
throw new TypeError('Unimplemented');
52+
}
53+
54+
get nextElementSibling(): ReadOnlyElement | null {
55+
throw new TypeError('Unimplemented');
56+
}
57+
58+
get previousElementSibling(): ReadOnlyElement | null {
59+
throw new TypeError('Unimplemented');
60+
}
61+
62+
get scrollHeight(): number {
63+
throw new TypeError('Unimplemented');
64+
}
65+
66+
get scrollLeft(): number {
67+
throw new TypeError('Unimplemented');
68+
}
69+
70+
get scrollTop(): number {
71+
throw new TypeError('Unimplemented');
72+
}
73+
74+
get scrollWidth(): number {
75+
throw new TypeError('Unimplemented');
76+
}
77+
78+
get tagName(): string {
79+
throw new TypeError('Unimplemented');
80+
}
81+
82+
getBoundingClientRect(): DOMRect {
83+
throw new TypeError('Unimplemented');
84+
}
85+
86+
getClientRects(): DOMRectList {
87+
throw new TypeError('Unimplemented');
88+
}
89+
}
+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
* @flow strict
9+
*/
10+
11+
// flowlint unsafe-getters-setters:off
12+
13+
import type NodeList from '../OldStyleCollections/NodeList';
14+
import type ReadOnlyElement from './ReadOnlyElement';
15+
16+
export default class ReadOnlyNode {
17+
get childNodes(): NodeList<ReadOnlyNode> {
18+
throw new TypeError('Unimplemented');
19+
}
20+
21+
get firstChild(): ReadOnlyNode | null {
22+
throw new TypeError('Unimplemented');
23+
}
24+
25+
get isConnected(): boolean {
26+
throw new TypeError('Unimplemented');
27+
}
28+
29+
get lastChild(): ReadOnlyNode | null {
30+
throw new TypeError('Unimplemented');
31+
}
32+
33+
get nextSibling(): ReadOnlyNode | null {
34+
throw new TypeError('Unimplemented');
35+
}
36+
37+
get nodeName(): string {
38+
throw new TypeError('Unimplemented');
39+
}
40+
41+
get nodeType(): number {
42+
throw new TypeError('Unimplemented');
43+
}
44+
45+
get nodeValue(): string | null {
46+
throw new TypeError('Unimplemented');
47+
}
48+
49+
get parentElement(): ReadOnlyElement | null {
50+
throw new TypeError('Unimplemented');
51+
}
52+
53+
get parentNode(): ReadOnlyNode | null {
54+
throw new TypeError('Unimplemented');
55+
}
56+
57+
get previousSibling(): ReadOnlyNode | null {
58+
throw new TypeError('Unimplemented');
59+
}
60+
61+
get textContent(): string | null {
62+
throw new TypeError('Unimplemented');
63+
}
64+
65+
compareDocumentPosition(otherNode: ReadOnlyNode): number {
66+
throw new TypeError('Unimplemented');
67+
}
68+
69+
contains(otherNode: ReadOnlyNode): boolean {
70+
throw new TypeError('Unimplemented');
71+
}
72+
73+
getRootNode(): ReadOnlyNode {
74+
throw new TypeError('Unimplemented');
75+
}
76+
77+
hasChildNodes(): boolean {
78+
throw new TypeError('Unimplemented');
79+
}
80+
81+
/*
82+
* Node types, as returned by the `nodeType` property.
83+
*/
84+
85+
/**
86+
* Type of Element, HTMLElement and ReactNativeElement instances.
87+
*/
88+
static ELEMENT_NODE: number = 1;
89+
/**
90+
* Currently Unused in React Native.
91+
*/
92+
static ATTRIBUTE_NODE: number = 2;
93+
/**
94+
* Text nodes.
95+
*/
96+
static TEXT_NODE: number = 3;
97+
/**
98+
* @deprecated Unused in React Native.
99+
*/
100+
static CDATA_SECTION_NODE: number = 4;
101+
/**
102+
* @deprecated
103+
*/
104+
static ENTITY_REFERENCE_NODE: number = 5;
105+
/**
106+
* @deprecated
107+
*/
108+
static ENTITY_NODE: number = 6;
109+
/**
110+
* @deprecated Unused in React Native.
111+
*/
112+
static PROCESSING_INSTRUCTION_NODE: number = 7;
113+
/**
114+
* @deprecated Unused in React Native.
115+
*/
116+
static COMMENT_NODE: number = 8;
117+
/**
118+
* @deprecated Unused in React Native.
119+
*/
120+
static DOCUMENT_NODE: number = 9;
121+
/**
122+
* @deprecated Unused in React Native.
123+
*/
124+
static DOCUMENT_TYPE_NODE: number = 10;
125+
/**
126+
* @deprecated Unused in React Native.
127+
*/
128+
static DOCUMENT_FRAGMENT_NODE: number = 11;
129+
/**
130+
* @deprecated
131+
*/
132+
static NOTATION_NODE: number = 12;
133+
134+
/*
135+
* Document position flags. Used to check the return value of
136+
* `compareDocumentPosition()`.
137+
*/
138+
139+
/**
140+
* Both nodes are in different documents.
141+
*/
142+
static DOCUMENT_POSITION_DISCONNECTED: number = 1;
143+
/**
144+
* `otherNode` precedes the node in either a pre-order depth-first traversal of a tree containing both
145+
* (e.g., as an ancestor or previous sibling or a descendant of a previous sibling or previous sibling of an ancestor)
146+
* or (if they are disconnected) in an arbitrary but consistent ordering.
147+
*/
148+
static DOCUMENT_POSITION_PRECEDING: number = 2;
149+
/**
150+
* `otherNode` follows the node in either a pre-order depth-first traversal of a tree containing both
151+
* (e.g., as a descendant or following sibling or a descendant of a following sibling or following sibling of an ancestor)
152+
* or (if they are disconnected) in an arbitrary but consistent ordering.
153+
*/
154+
static DOCUMENT_POSITION_FOLLOWING: number = 4;
155+
/**
156+
* `otherNode` is an ancestor of the node.
157+
*/
158+
static DOCUMENT_POSITION_CONTAINS: number = 8;
159+
/**
160+
* `otherNode` is a descendant of the node.
161+
*/
162+
static DOCUMENT_POSITION_CONTAINED_BY: number = 16;
163+
/**
164+
* @deprecated Unused in React Native.
165+
*/
166+
static DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number = 32;
167+
}

0 commit comments

Comments
 (0)