From 8dfd1dce3a2057cd0ce407f5171c19e37c9d3084 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Tue, 6 Aug 2024 17:51:47 +0200 Subject: [PATCH] refactor(cdk/drag-drop): remove unnecessary type (#29541) Removes the `RootNode` internal type since it isn't necessary anymore. (cherry picked from commit ef21b82787903de3169bf14df7758520a58fd29d) --- src/cdk/drag-drop/drop-list-ref.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/cdk/drag-drop/drop-list-ref.ts b/src/cdk/drag-drop/drop-list-ref.ts index b4540e803d6c..983a04943fb3 100644 --- a/src/cdk/drag-drop/drop-list-ref.ts +++ b/src/cdk/drag-drop/drop-list-ref.ts @@ -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. */ @@ -181,7 +174,7 @@ export class DropListRef { private readonly _stopScrollTimers = new Subject(); /** 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; @@ -760,10 +753,10 @@ export class DropListRef { * 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;