Skip to content

Commit

Permalink
Move geometry to its own directory outside dom (facebook#49100)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#49100

Changelog: [internal]

This API isn't part of the DOM standard so can be moved out.

Differential Revision: D68896484
  • Loading branch information
rubennorte authored and facebook-github-bot committed Feb 3, 2025
1 parent 71ad636 commit a67c138
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10479,53 +10479,6 @@ declare export default Spec;
"
`;

exports[`public API should not change unintentionally src/private/webapis/dom/geometry/DOMRect.js 1`] = `
"declare export default class DOMRect extends DOMRectReadOnly {
get x(): number;
set x(x: ?number): void;
get y(): number;
set y(y: ?number): void;
get width(): number;
set width(width: ?number): void;
get height(): number;
set height(height: ?number): void;
static fromRect(rect?: ?DOMRectInit): DOMRect;
}
"
`;

exports[`public API should not change unintentionally src/private/webapis/dom/geometry/DOMRectReadOnly.js 1`] = `
"export interface DOMRectInit {
x?: ?number;
y?: ?number;
width?: ?number;
height?: ?number;
}
declare export default class DOMRectReadOnly {
constructor(x: ?number, y: ?number, width: ?number, height: ?number): void;
get x(): number;
get y(): number;
get width(): number;
get height(): number;
get top(): number;
get right(): number;
get bottom(): number;
get left(): number;
toJSON(): {
x: number,
y: number,
width: number,
height: number,
top: number,
left: number,
bottom: number,
right: number,
};
static fromRect(rect?: ?DOMRectInit): DOMRectReadOnly;
}
"
`;

exports[`public API should not change unintentionally src/private/webapis/dom/nodes/ReactNativeDocument.js 1`] = `
"declare export default class ReactNativeDocument extends ReadOnlyNode {
constructor(
Expand Down Expand Up @@ -10683,23 +10636,6 @@ exports[`public API should not change unintentionally src/private/webapis/dom/no
"
`;

exports[`public API should not change unintentionally src/private/webapis/dom/oldstylecollections/ArrayLikeUtils.js 1`] = `
"export interface ArrayLike<T> extends Iterable<T> {
[indexer: number]: T;
+length: number;
}
declare export function createValueIterator<T>(
arrayLike: ArrayLike<T>
): Iterator<T>;
declare export function createKeyIterator<T>(
arrayLike: ArrayLike<T>
): Iterator<number>;
declare export function createEntriesIterator<T>(
arrayLike: ArrayLike<T>
): Iterator<[number, T]>;
"
`;

exports[`public API should not change unintentionally src/private/webapis/intersectionobserver/IntersectionObserver.js 1`] = `
"export type IntersectionObserverCallback = (
entries: Array<IntersectionObserverEntry>,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/src/private/setup/setUpDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ export default function setUpDOM() {

polyfillGlobal(
'DOMRect',
() => require('../webapis/dom/geometry/DOMRect').default,
() => require('../webapis/geometry/DOMRect').default,
);

polyfillGlobal(
'DOMRectReadOnly',
() => require('../webapis/dom/geometry/DOMRectReadOnly').default,
() => require('../webapis/geometry/DOMRectReadOnly').default,
);

polyfillGlobal(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import type HTMLCollection from '../oldstylecollections/HTMLCollection';

import DOMRect from '../geometry/DOMRect';
import DOMRect from '../../geometry/DOMRect';
import {createHTMLCollection} from '../oldstylecollections/HTMLCollection';
import {
getInstanceHandle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

// flowlint unsafe-getters-setters:off

import type {ArrayLike} from './ArrayLikeUtils';
import type {ArrayLike} from '../../utils/ArrayLikeUtils';

import {createValueIterator} from './ArrayLikeUtils';
import {createValueIterator} from '../../utils/ArrayLikeUtils';

// IMPORTANT: The type definition for this module is defined in `HTMLCollection.js.flow`
// because Flow only supports indexers in classes in declaration files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @flow strict
*/

import type {ArrayLike} from './ArrayLikeUtils';
import type {ArrayLike} from '../../utils/ArrayLikeUtils';

declare export default class HTMLCollection<+T>
implements Iterable<T>, ArrayLike<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

// flowlint unsafe-getters-setters:off

import type {ArrayLike} from './ArrayLikeUtils';
import type {ArrayLike} from '../../utils/ArrayLikeUtils';

import {
createEntriesIterator,
createKeyIterator,
createValueIterator,
} from './ArrayLikeUtils';
} from '../../utils/ArrayLikeUtils';

// IMPORTANT: The Flow type definition for this module is defined in `NodeList.js.flow`
// because Flow only supports indexers in classes in declaration files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @flow strict
*/

import type {ArrayLike} from './ArrayLikeUtils';
import type {ArrayLike} from '../../utils/ArrayLikeUtils';

declare export default class NodeList<+T> implements Iterable<T>, ArrayLike<T> {
// This property should've been read-only as well, but Flow doesn't handle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

// flowlint unsafe-getters-setters:off

import type DOMRectReadOnly from '../geometry/DOMRectReadOnly';
import type {ArrayLike} from './ArrayLikeUtils';
import type {ArrayLike} from '../utils/ArrayLikeUtils';
import type DOMRectReadOnly from './DOMRectReadOnly';

import {createValueIterator} from './ArrayLikeUtils';
import {createValueIterator} from '../utils/ArrayLikeUtils';

// IMPORTANT: The Flow type definition for this module is defined in `DOMRectList.js.flow`
// because Flow only supports indexers in classes in declaration files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* @flow strict
*/

import type DOMRectReadOnly from '../geometry/DOMRectReadOnly';
import type {ArrayLike} from './ArrayLikeUtils';
import type {ArrayLike} from '../utils/ArrayLikeUtils';
import type DOMRectReadOnly from './DOMRectReadOnly';

declare export default class DOMRectList
implements Iterable<DOMRectReadOnly>, ArrayLike<DOMRectReadOnly>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
* @oncall react_native
*/

import DOMRectReadOnly from '../../geometry/DOMRectReadOnly';
import {createDOMRectList} from '../DOMRectList';
import DOMRectReadOnly from '../DOMRectReadOnly';

const domRectA = new DOMRectReadOnly();
const domRectB = new DOMRectReadOnly();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import type ReactNativeElement from '../dom/nodes/ReactNativeElement';
import type {NativeIntersectionObserverEntry} from './specs/NativeIntersectionObserver';

import DOMRectReadOnly from '../dom/geometry/DOMRectReadOnly';
import DOMRectReadOnly from '../geometry/DOMRectReadOnly';

/**
* The [`IntersectionObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/* eslint-disable lint/sort-imports */
import type IntersectionObserverType from '../IntersectionObserver';

import DOMRectReadOnly from '../../dom/geometry/DOMRectReadOnly';
import DOMRectReadOnly from '../../geometry/DOMRectReadOnly';
import Fantom from '@react-native/fantom';
import setUpIntersectionObserver from '../../../setup/setUpIntersectionObserver';
import ReactNativeElement from '../../dom/nodes/ReactNativeElement';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* @format
*/

import type DOMRectReadOnly from 'react-native/src/private/webapis/dom/geometry/DOMRectReadOnly';
import type ReadOnlyNode from 'react-native/src/private/webapis/dom/nodes/ReadOnlyNode';
import type DOMRectReadOnly from 'react-native/src/private/webapis/geometry/DOMRectReadOnly';

import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/ReactNativeElement';
import IntersectionObserver from 'react-native/src/private/webapis/intersectionobserver/IntersectionObserver';
Expand Down

0 comments on commit a67c138

Please sign in to comment.