mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor(focus-monitor): make checkChildren parameter optional (#9384)
After we made the `renderer` param optional, `checkChildren` became required when using the two-param signature. These changes make it optional which is slightly more convenient on consumption.
This commit is contained in:
committed by
Jeremy Elbourn
parent
b491f7afab
commit
9177fbf766
@@ -30,7 +30,7 @@ describe('FocusMonitor', () => {
|
||||
focusMonitor = fm;
|
||||
|
||||
changeHandler = jasmine.createSpy('focus origin change handler');
|
||||
focusMonitor.monitor(buttonElement, false).subscribe(changeHandler);
|
||||
focusMonitor.monitor(buttonElement).subscribe(changeHandler);
|
||||
patchElementFocus(buttonElement);
|
||||
}));
|
||||
|
||||
|
||||
@@ -82,10 +82,10 @@ export class FocusMonitor {
|
||||
* @returns An observable that emits when the focus state of the element changes.
|
||||
* When the element is blurred, null will be emitted.
|
||||
*/
|
||||
monitor(element: HTMLElement, checkChildren: boolean): Observable<FocusOrigin>;
|
||||
monitor(element: HTMLElement, checkChildren?: boolean): Observable<FocusOrigin>;
|
||||
monitor(
|
||||
element: HTMLElement,
|
||||
renderer: Renderer2 | boolean,
|
||||
renderer?: Renderer2 | boolean,
|
||||
checkChildren?: boolean): Observable<FocusOrigin> {
|
||||
// TODO(mmalerba): clean up after deprecated signature is removed.
|
||||
if (!(renderer instanceof Renderer2)) {
|
||||
|
||||
@@ -215,7 +215,7 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
|
||||
|
||||
ngAfterViewInit() {
|
||||
this._focusMonitor
|
||||
.monitor(this._inputElement.nativeElement, false)
|
||||
.monitor(this._inputElement.nativeElement)
|
||||
.subscribe(focusOrigin => this._onInputFocusChange(focusOrigin));
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ export class MatExpansionPanelHeader implements OnDestroy {
|
||||
)
|
||||
.subscribe(() => this._changeDetectorRef.markForCheck());
|
||||
|
||||
_focusMonitor.monitor(_element.nativeElement, false);
|
||||
_focusMonitor.monitor(_element.nativeElement);
|
||||
}
|
||||
|
||||
/** Height of the header while the panel is expanded. */
|
||||
|
||||
@@ -533,7 +533,7 @@ export class MatRadioButton extends _MatRadioButtonMixinBase
|
||||
|
||||
ngAfterViewInit() {
|
||||
this._focusMonitor
|
||||
.monitor(this._inputElement.nativeElement, false)
|
||||
.monitor(this._inputElement.nativeElement)
|
||||
.subscribe(focusOrigin => this._onInputFocusChange(focusOrigin));
|
||||
}
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ export class MatSlideToggle extends _MatSlideToggleMixinBase implements OnDestro
|
||||
this._slideRenderer = new SlideToggleRenderer(this._elementRef, this._platform);
|
||||
|
||||
this._focusMonitor
|
||||
.monitor(this._inputElement.nativeElement, false)
|
||||
.monitor(this._inputElement.nativeElement)
|
||||
.subscribe(focusOrigin => this._onInputFocusChange(focusOrigin));
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ export class MatTooltip implements OnDestroy {
|
||||
element.style.webkitUserSelect = element.style.userSelect = '';
|
||||
}
|
||||
|
||||
_focusMonitor.monitor(element, false).subscribe(origin => {
|
||||
_focusMonitor.monitor(element).subscribe(origin => {
|
||||
// Note that the focus monitor runs outside the Angular zone.
|
||||
if (!origin) {
|
||||
_ngZone.run(() => this.hide(0));
|
||||
|
||||
Reference in New Issue
Block a user