Skip to content

Commit

Permalink
fix(cdk/platform): preserve compatibility with angular versions less …
Browse files Browse the repository at this point in the history
…than 19.1 (#30401) (#30407)

Fixes that we were importing a symbol only available in Angular 19.1, even though our peer dependencies allow 19.0.x.

Fixes #30388.
  • Loading branch information
crisbeto authored Jan 28, 2025
1 parent be49103 commit b72838b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/cdk/platform/features/backwards-compatibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@
* found in the LICENSE file at https://angular.dev/license
*/

import {Renderer2, VERSION, ListenerOptions} from '@angular/core';
import {Renderer2, VERSION} from '@angular/core';

// TODO(crisbeto): replace interface with the one from core when making breaking changes for v20.
/** Options when binding events manually. */
export interface _ListenerOptions {
capture?: boolean;
once?: boolean;
passive?: boolean;
}

// TODO(crisbeto): remove this function when making breaking changes for v20.
/**
Expand All @@ -20,7 +28,7 @@ export function _bindEventWithOptions(
target: EventTarget,
eventName: string,
callback: (event: any) => boolean | void,
options: ListenerOptions,
options: _ListenerOptions,
): () => void {
const major = parseInt(VERSION.major);
const minor = parseInt(VERSION.minor);
Expand Down
13 changes: 11 additions & 2 deletions tools/public_api_guard/cdk/platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
```ts

import * as i0 from '@angular/core';
import { ListenerOptions } from '@angular/core';
import { Renderer2 } from '@angular/core';

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

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

// @public
export interface _ListenerOptions {
// (undocumented)
capture?: boolean;
// (undocumented)
once?: boolean;
// (undocumented)
passive?: boolean;
}

// @public
export function normalizePassiveListenerOptions(options: AddEventListenerOptions): AddEventListenerOptions | boolean;

Expand Down

0 comments on commit b72838b

Please sign in to comment.