Skip to content

refactor(cdk/drag-drop): remove unnecessary type #29541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading