Skip to content

Commit de40f2e

Browse files
authored
fix(cdk/platform): preserve compatibility with angular versions less than 19.1 (angular#30401)
Fixes that we were importing a symbol only available in Angular 19.1, even though our peer dependencies allow 19.0.x. Fixes angular#30388.
1 parent be74ffe commit de40f2e

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

src/cdk/drag-drop/drag-drop-registry.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
ChangeDetectionStrategy,
1111
Component,
1212
Injectable,
13-
ListenerOptions,
1413
NgZone,
1514
OnDestroy,
1615
RendererFactory2,
@@ -20,7 +19,7 @@ import {
2019
signal,
2120
} from '@angular/core';
2221
import {DOCUMENT} from '@angular/common';
23-
import {_bindEventWithOptions} from '@angular/cdk/platform';
22+
import {_bindEventWithOptions, _ListenerOptions} from '@angular/cdk/platform';
2423
import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
2524
import {Observable, Observer, Subject, merge} from 'rxjs';
2625
import type {DropListRef} from './drop-list-ref';
@@ -178,7 +177,7 @@ export class DragDropRegistry<_ = unknown, __ = unknown> implements OnDestroy {
178177
const isTouchEvent = event.type.startsWith('touch');
179178
const endEventHandler = (e: Event) => this.pointerUp.next(e as TouchEvent | MouseEvent);
180179

181-
const toBind: [name: string, handler: (event: Event) => void, options: ListenerOptions][] = [
180+
const toBind: [name: string, handler: (event: Event) => void, options: _ListenerOptions][] = [
182181
// Use capturing so that we pick up scroll changes in any scrollable nodes that aren't
183182
// the document. See https://github.com/angular/components/issues/17144.
184183
['scroll', (e: Event) => this.scroll.next(e), capturingEventOptions],

src/cdk/platform/features/backwards-compatibility.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {Renderer2, VERSION, ListenerOptions} from '@angular/core';
9+
import {Renderer2, VERSION} from '@angular/core';
10+
11+
// TODO(crisbeto): replace interface with the one from core when making breaking changes for v20.
12+
/** Options when binding events manually. */
13+
export interface _ListenerOptions {
14+
capture?: boolean;
15+
once?: boolean;
16+
passive?: boolean;
17+
}
1018

1119
// TODO(crisbeto): remove this function when making breaking changes for v20.
1220
/**
@@ -20,7 +28,7 @@ export function _bindEventWithOptions(
2028
target: EventTarget,
2129
eventName: string,
2230
callback: (event: any) => boolean | void,
23-
options: ListenerOptions,
31+
options: _ListenerOptions,
2432
): () => void {
2533
const major = parseInt(VERSION.major);
2634
const minor = parseInt(VERSION.minor);

tools/public_api_guard/cdk/platform.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
```ts
66

77
import * as i0 from '@angular/core';
8-
import { ListenerOptions } from '@angular/core';
98
import { Renderer2 } from '@angular/core';
109

1110
// @public
12-
export function _bindEventWithOptions(renderer: Renderer2, target: EventTarget, eventName: string, callback: (event: any) => boolean | void, options: ListenerOptions): () => void;
11+
export function _bindEventWithOptions(renderer: Renderer2, target: EventTarget, eventName: string, callback: (event: any) => boolean | void, options: _ListenerOptions): () => void;
1312

1413
// @public
1514
export function _getEventTarget<T extends EventTarget>(event: Event): T | null;
@@ -29,6 +28,16 @@ export function getSupportedInputTypes(): Set<string>;
2928
// @public
3029
export function _isTestEnvironment(): boolean;
3130

31+
// @public
32+
export interface _ListenerOptions {
33+
// (undocumented)
34+
capture?: boolean;
35+
// (undocumented)
36+
once?: boolean;
37+
// (undocumented)
38+
passive?: boolean;
39+
}
40+
3241
// @public
3342
export function normalizePassiveListenerOptions(options: AddEventListenerOptions): AddEventListenerOptions | boolean;
3443

0 commit comments

Comments
 (0)