refactor: add utility for coercing element refs (#14258)

Since we're having more and more APIs that accept both an `ElementRef` and an `Element`, we have a few places that repeat the same logic for coercing the value to an `Element`. These changes add a utility function that can be used everywhere.
This commit is contained in:
Kristiyan Kostadinov
2018-12-19 16:13:28 +01:00
committed by Jeremy Elbourn
parent e673608476
commit 2463200324
10 changed files with 52 additions and 17 deletions
+2 -2
View File
@@ -70,10 +70,10 @@ export declare class FocusKeyManager<T> extends ListKeyManager<FocusableOption &
export declare class FocusMonitor implements OnDestroy {
constructor(_ngZone: NgZone, _platform: Platform);
_onBlur(event: FocusEvent, element: HTMLElement): void;
focusVia(element: ElementRef<HTMLElement>, origin: FocusOrigin, options?: FocusOptions): void;
focusVia(element: HTMLElement, origin: FocusOrigin, options?: FocusOptions): void;
monitor(element: HTMLElement, checkChildren?: boolean): Observable<FocusOrigin>;
focusVia(element: ElementRef<HTMLElement>, origin: FocusOrigin, options?: FocusOptions): void;
monitor(element: ElementRef<HTMLElement>, checkChildren?: boolean): Observable<FocusOrigin>;
monitor(element: HTMLElement, checkChildren?: boolean): Observable<FocusOrigin>;
ngOnDestroy(): void;
stopMonitoring(element: ElementRef<HTMLElement>): void;
stopMonitoring(element: HTMLElement): void;
+2
View File
@@ -6,5 +6,7 @@ export declare function coerceBooleanProperty(value: any): boolean;
export declare function coerceCssPixelValue(value: any): string;
export declare function coerceElement<T>(elementOrRef: ElementRef<T> | T): T;
export declare function coerceNumberProperty(value: any): number;
export declare function coerceNumberProperty<D>(value: any, fallback: D): number | D;