Skip to content

Commit

Permalink
fix(button): reuse _getHostElement() to avoid redundant elementRef.na…
Browse files Browse the repository at this point in the history
…tiveElement calls (angular#2625)
  • Loading branch information
codef0rmerz authored and mmalerba committed Jan 19, 2017
1 parent e2ad3a0 commit c7d1c17
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class MdButton {

_setElementColor(color: string, isAdd: boolean) {
if (color != null && color != '') {
this._renderer.setElementClass(this._elementRef.nativeElement, `md-${color}`, isAdd);
this._renderer.setElementClass(this._getHostElement(), `md-${color}`, isAdd);
}
}

Expand All @@ -96,15 +96,15 @@ export class MdButton {

/** Focuses the button. */
focus(): void {
this._renderer.invokeElementMethod(this._elementRef.nativeElement, 'focus');
this._renderer.invokeElementMethod(this._getHostElement(), 'focus');
}

_getHostElement() {
return this._elementRef.nativeElement;
}

_isRoundButton() {
const el = this._elementRef.nativeElement;
const el = this._getHostElement();
return el.hasAttribute('md-icon-button') ||
el.hasAttribute('md-fab') ||
el.hasAttribute('md-mini-fab');
Expand Down

0 comments on commit c7d1c17

Please sign in to comment.