mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
chore(button): switch MdAnchor to OnPush change detection (#5557)
* Switches the `MdAnchor` component to `OnPush` change detection. * Gets rid of a `@HostBinding` in favor of using the `host`. Relates to #5035.
This commit is contained in:
committed by
mmalerba
parent
d5e42cb656
commit
b31a304fcc
@@ -12,14 +12,13 @@ import {
|
||||
Directive,
|
||||
ElementRef,
|
||||
forwardRef,
|
||||
HostBinding,
|
||||
Input,
|
||||
OnDestroy,
|
||||
Optional,
|
||||
Renderer2,
|
||||
Self,
|
||||
ViewEncapsulation,
|
||||
Inject
|
||||
Inject,
|
||||
} from '@angular/core';
|
||||
import {coerceBooleanProperty, FocusOriginMonitor, Platform} from '../core';
|
||||
import {mixinDisabled, CanDisable} from '../core/common-behaviors/disabled';
|
||||
@@ -193,6 +192,7 @@ export class MdButton extends _MdButtonMixinBase implements OnDestroy, CanDisabl
|
||||
selector: `a[md-button], a[md-raised-button], a[md-icon-button], a[md-fab], a[md-mini-fab],
|
||||
a[mat-button], a[mat-raised-button], a[mat-icon-button], a[mat-fab], a[mat-mini-fab]`,
|
||||
host: {
|
||||
'[attr.tabindex]': 'disabled ? -1 : 0',
|
||||
'[attr.disabled]': 'disabled || null',
|
||||
'[attr.aria-disabled]': 'disabled.toString()',
|
||||
'(click)': '_haltDisabledEvents($event)',
|
||||
@@ -200,7 +200,8 @@ export class MdButton extends _MdButtonMixinBase implements OnDestroy, CanDisabl
|
||||
inputs: ['disabled', 'color'],
|
||||
templateUrl: 'button.html',
|
||||
styleUrls: ['button.css'],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class MdAnchor extends MdButton {
|
||||
constructor(
|
||||
@@ -211,12 +212,6 @@ export class MdAnchor extends MdButton {
|
||||
super(renderer, elementRef, platform, focusOriginMonitor);
|
||||
}
|
||||
|
||||
/** @docs-private */
|
||||
@HostBinding('tabIndex')
|
||||
get tabIndex(): number {
|
||||
return this.disabled ? -1 : 0;
|
||||
}
|
||||
|
||||
_haltDisabledEvents(event: Event) {
|
||||
// A disabled button shouldn't apply any actions
|
||||
if (this.disabled) {
|
||||
|
||||
Reference in New Issue
Block a user