Skip to content

Commit

Permalink
refactor(cdk/drag-drop): remove unnecessary type (#29541)
Browse files Browse the repository at this point in the history
Removes the `RootNode` internal type since it isn't necessary anymore.

(cherry picked from commit ef21b82)
  • Loading branch information
crisbeto committed Aug 6, 2024
1 parent 2b5ae8c commit 8dfd1dc
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/cdk/drag-drop/drop-list-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ enum AutoScrollHorizontalDirection {
RIGHT,
}

type RootNode = DocumentOrShadowRoot & {
// As of TS 4.4 the built in DOM typings don't include `elementFromPoint` on `ShadowRoot`,
// even though it exists (see https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot).
// This type is a utility to avoid having to add casts everywhere.
elementFromPoint(x: number, y: number): Element | null;
};

/**
* Reference to a drop list. Used to manipulate or dispose of the container.
*/
Expand Down Expand Up @@ -181,7 +174,7 @@ export class DropListRef<T = any> {
private readonly _stopScrollTimers = new Subject<void>();

/** Shadow root of the current element. Necessary for `elementFromPoint` to resolve correctly. */
private _cachedShadowRoot: RootNode | null = null;
private _cachedShadowRoot: DocumentOrShadowRoot | null = null;

/** Reference to the document. */
private _document: Document;
Expand Down Expand Up @@ -760,10 +753,10 @@ export class DropListRef<T = any> {
* in order to ensure that the element has been moved into the shadow DOM. Doing it inside the
* constructor might be too early if the element is inside of something like `ngFor` or `ngIf`.
*/
private _getShadowRoot(): RootNode {
private _getShadowRoot(): DocumentOrShadowRoot {
if (!this._cachedShadowRoot) {
const shadowRoot = _getShadowRoot(this._container);
this._cachedShadowRoot = (shadowRoot || this._document) as RootNode;
this._cachedShadowRoot = shadowRoot || this._document;
}

return this._cachedShadowRoot;
Expand Down

0 comments on commit 8dfd1dc

Please sign in to comment.